Added missing weight emails
Deploy / deploy-dev (push) Successful in 2m15s
Deploy / deploy-prod (push) Skipped

This commit is contained in:
blaisadmin committed 2026-09-05 22:51:39 -04:00
1 parent b4254a68fa
commit 5abc7f6174
13 files changed
+501

No files matched your search

+14
View File
@@ -1,3 +1,4 @@
import type { WeightReminder } from './reminders/weightReminders.js';
import crypto from 'crypto';
import { existsSync } from 'fs';
import path from 'path';
@@ -2270,6 +2271,19 @@ export const runBirdMilestoneReminders = async (runDate = getDateInTimeZone()) =
};
};
export const sendWeightReminderNotification = async (reminders: WeightReminder[]): Promise<boolean> => {
if (!mailTransport || !reminders.length) return false;
const first = reminders[0];
const result = await mailTransport.sendMail({
from: smtpFromName ? `"${smtpFromName}" <${smtpFromEmail}>` : smtpFromEmail,
to: first.recipient,
subject: `Weight reminders for ${first.workspace_name}`,
text: `These birds in ${first.workspace_name} haven't had a new weight entry in at least 48 hours:\n\n${reminders.map((bird) => `- ${bird.bird_name}`).join('\n')}\n\nOpen FlockPal to record their weights: ${frontendBaseUrl}`,
html: `<p>These birds in ${escapeHtml(first.workspace_name)} haven't had a new weight entry in at least 48 hours:</p><ul>${reminders.map((bird) => `<li>${escapeHtml(bird.bird_name)}</li>`).join('')}</ul><p><a href="${escapeHtml(frontendBaseUrl)}">Open FlockPal to record their weights</a></p>`,
});
return result.accepted.length > 0;
};
export const runMedicationReminders = async (runDate = getDateInTimeZone(), currentTime = getTimeInTimeZone()) => {
const reminders = await listDueMedicationReminders(runDate, currentTime);
let sent = 0;