Fixed email designs
This commit is contained in:
1 parent
856753b012
commit
b1b89ad334
15 files changed
+302
-188
No files matched your search
+50
-185
@@ -1,3 +1,5 @@
|
||||
import { buildEmailLayout } from './emails/emailLayout.js';
|
||||
import { buildWeightReminderEmail } from './emails/weightReminderEmail.js';
|
||||
import type { WeightReminder } from './reminders/weightReminders.js';
|
||||
import crypto from 'crypto';
|
||||
import { existsSync } from 'fs';
|
||||
@@ -9,7 +11,7 @@ import express, { type NextFunction, type Request, type Response } from 'express
|
||||
import rateLimit from 'express-rate-limit';
|
||||
import helmet from 'helmet';
|
||||
import morgan from 'morgan';
|
||||
import nodemailer, { type SendMailOptions } from 'nodemailer';
|
||||
import nodemailer from 'nodemailer';
|
||||
import Stripe from 'stripe';
|
||||
import { z } from 'zod';
|
||||
|
||||
@@ -1395,12 +1397,14 @@ const sendMagicLink = async ({
|
||||
'',
|
||||
'This link expires in 15 minutes and can only be used once.',
|
||||
].join('\n'),
|
||||
html: `
|
||||
<p>Hi ${name || 'there'},</p>
|
||||
...await buildEmailLayout({ eyebrow: 'Sign in', headline: 'Your FlockPal sign-in link',
|
||||
contentHtml: `
|
||||
<p>Hi ${escapeHtml(name || 'there')},</p>
|
||||
<p>Use this secure link to sign in to FlockPal:</p>
|
||||
<p><a href="${magicLinkUrl}">Sign in to FlockPal</a></p>
|
||||
<p>This link expires in 15 minutes and can only be used once.</p>
|
||||
`,
|
||||
`,
|
||||
action: { url: magicLinkUrl, label: 'Sign in to FlockPal' },
|
||||
}),
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -1471,27 +1475,6 @@ const getMilestoneYearCount = (reminder: BirdMilestoneReminderCandidateRow) => {
|
||||
return Number.isFinite(sourceYear) ? Math.max(0, reminder.reminder_year - sourceYear) : 0;
|
||||
};
|
||||
|
||||
const getFlockPalLogoAttachment = () => {
|
||||
const logoPath = path.join(process.cwd(), 'assets', 'flockpal-logo.png');
|
||||
|
||||
if (!existsSync(logoPath)) {
|
||||
console.warn(`Unable to load FlockPal email logo from ${logoPath}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
filename: 'flockpal-logo.png',
|
||||
path: logoPath,
|
||||
cid: 'flockpal-logo',
|
||||
contentDisposition: 'inline' as const,
|
||||
};
|
||||
};
|
||||
|
||||
const getEmailTrackPatternDataUrl = () => {
|
||||
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="680" height="188" viewBox="0 0 680 188"><defs><linearGradient id="wash" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#fef5e7"/><stop offset=".52" stop-color="#e9ddba"/><stop offset="1" stop-color="#d9eadf"/></linearGradient><symbol id="track" viewBox="0 0 160 160"><rect x="66" y="12" width="28" height="136" rx="14" transform="rotate(30 80 80)"/><rect x="66" y="12" width="28" height="136" rx="14" transform="rotate(-30 80 80)"/></symbol></defs><rect width="680" height="188" fill="url(#wash)"/><g opacity=".68"><use href="#track" x="20" y="16" width="88" height="88" fill="#5bb3b7" transform="rotate(-12 64 60)"/><use href="#track" x="126" y="74" width="78" height="78" fill="#7eb773" transform="rotate(18 165 113)"/><use href="#track" x="232" y="20" width="104" height="104" fill="#f3a24a" transform="rotate(-26 284 72)"/><use href="#track" x="378" y="72" width="86" height="86" fill="#898b93" transform="rotate(28 421 115)"/><use href="#track" x="492" y="18" width="98" height="98" fill="#b9c945" transform="rotate(-18 541 67)"/><use href="#track" x="592" y="84" width="66" height="66" fill="#5bb3b7" transform="rotate(34 625 117)"/></g><g opacity=".32"><use href="#track" x="66" y="112" width="46" height="46" fill="#f3a24a" transform="rotate(36 89 135)"/><use href="#track" x="190" y="122" width="42" height="42" fill="#5bb3b7" transform="rotate(-20 211 143)"/><use href="#track" x="344" y="18" width="44" height="44" fill="#7eb773" transform="rotate(18 366 40)"/><use href="#track" x="474" y="126" width="48" height="48" fill="#f3a24a" transform="rotate(-34 498 150)"/><use href="#track" x="626" y="18" width="42" height="42" fill="#898b93" transform="rotate(22 647 39)"/></g></svg>`;
|
||||
return `data:image/svg+xml,${encodeURIComponent(svg)}`;
|
||||
};
|
||||
|
||||
const parseDataImage = (dataUrl: string) => {
|
||||
const match = /^data:(image\/[a-zA-Z0-9.+-]+);base64,(.+)$/.exec(dataUrl);
|
||||
if (!match) {
|
||||
@@ -1636,22 +1619,6 @@ const loadBirdReportPhotoBuffer = async (bird: BirdRow) => {
|
||||
return Buffer.from(await imageResponse.arrayBuffer());
|
||||
};
|
||||
|
||||
const getDefaultBirdPhotoAttachment = () => {
|
||||
const defaultPhotoPath = path.join(process.cwd(), 'assets', 'yoda-default.png');
|
||||
|
||||
if (!existsSync(defaultPhotoPath)) {
|
||||
console.warn(`Unable to load default bird photo from ${defaultPhotoPath}`);
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
filename: 'yoda-default.png',
|
||||
path: defaultPhotoPath,
|
||||
cid: 'flockpal-default-bird-photo',
|
||||
contentDisposition: 'inline' as const,
|
||||
};
|
||||
};
|
||||
|
||||
const sendRescueStatusNotification = async ({
|
||||
workspace,
|
||||
ownerEmail,
|
||||
@@ -1701,7 +1668,8 @@ const sendRescueStatusNotification = async ({
|
||||
to: rescueStatusNotificationEmail,
|
||||
subject,
|
||||
text: lines.join('\n'),
|
||||
html: `
|
||||
...await buildEmailLayout({ eyebrow: 'Rescue status', headline: 'Rescue flock update',
|
||||
contentHtml: `
|
||||
<p>A rescue flock was ${eventLabel}.</p>
|
||||
<ul>
|
||||
<li><strong>Rescue flock:</strong> ${escapedWorkspaceName}</li>
|
||||
@@ -1711,7 +1679,9 @@ const sendRescueStatusNotification = async ({
|
||||
<li><strong>Flock ID:</strong> ${workspace.id}</li>
|
||||
</ul>
|
||||
${escapedNote ? `<p><strong>Note:</strong> ${escapedNote}</p>` : ''}
|
||||
`,
|
||||
`,
|
||||
action: { url: frontendBaseUrl, label: 'Open FlockPal' },
|
||||
}),
|
||||
});
|
||||
|
||||
return { delivered: true };
|
||||
@@ -1850,13 +1820,15 @@ const issueBirdTransferInvite = async ({
|
||||
to: email,
|
||||
subject,
|
||||
text,
|
||||
html: `
|
||||
...await buildEmailLayout({ eyebrow: 'Bird transfer', headline: 'A bird is joining your flock',
|
||||
contentHtml: `
|
||||
<p>Hi there,</p>
|
||||
<p><strong>${escapeHtml(sourceWorkspaceName)}</strong> wants to transfer <strong>${escapeHtml(birdName)}</strong> to your FlockPal account.</p>
|
||||
<p>Use this secure invite link to sign in or create your account. FlockPal will automatically create your receiving flock and complete any pending bird transfers for this email.</p>
|
||||
<p><a href="${magicLinkUrl}">Accept bird transfer in FlockPal</a></p>
|
||||
<p>This link expires in 15 minutes and can only be used once.</p>
|
||||
`,
|
||||
`,
|
||||
action: { url: magicLinkUrl, label: 'Accept bird transfer' },
|
||||
}),
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -1912,7 +1884,8 @@ const sendLostBirdReportNotification = async ({
|
||||
replyTo: emptyToNull(report.finderEmail) ?? undefined,
|
||||
subject,
|
||||
text: lines.join('\n'),
|
||||
html: `
|
||||
...await buildEmailLayout({ eyebrow: 'Found bird report', headline: 'A possible match for your bird',
|
||||
contentHtml: `
|
||||
<p>A possible found bird report was submitted for <strong>${escapeHtml(bird.name)}</strong>.</p>
|
||||
<ul>
|
||||
<li><strong>Band ID:</strong> ${escapeHtml(bird.tag_id ?? 'Not recorded')}</li>
|
||||
@@ -1924,7 +1897,9 @@ const sendLostBirdReportNotification = async ({
|
||||
<li><strong>Message:</strong> ${escapeHtml(message)}</li>
|
||||
</ul>
|
||||
<p>FlockPal does not verify found bird reports. Please use care before sharing personal information or arranging a pickup.</p>
|
||||
`,
|
||||
`,
|
||||
action: { url: frontendBaseUrl, label: 'Open FlockPal' },
|
||||
}),
|
||||
});
|
||||
|
||||
return { delivered: true };
|
||||
@@ -2000,7 +1975,7 @@ const buildMedicationReminderCopy = (reminder: MedicationReminderCandidateRow) =
|
||||
return {
|
||||
subject: `${reminder.medication_name} reminder for ${reminder.name}`,
|
||||
eyebrow: 'Medication Reminder',
|
||||
headline: `${slotLabel} time for ${reminder.name}`,
|
||||
headline: `Medication time for ${reminder.name}`,
|
||||
intro: `${reminder.name} is due for ${reminder.medication_name} at ${doseTime}.`,
|
||||
body: `Dose: ${reminder.dosage}${route}.`,
|
||||
detailLabel: `${slotLabel} at ${doseTime}`,
|
||||
@@ -2021,32 +1996,6 @@ const sendBirdMilestoneReminderNotification = async ({
|
||||
}
|
||||
|
||||
const copy = buildBirdMilestoneReminderCopy(reminder);
|
||||
const attachments: NonNullable<SendMailOptions['attachments']> = [];
|
||||
const logoAttachment = getFlockPalLogoAttachment();
|
||||
const trackPatternDataUrl = getEmailTrackPatternDataUrl();
|
||||
const uploadedBirdPhoto = reminder.photo_data_url ? parseDataImage(reminder.photo_data_url) : null;
|
||||
const defaultBirdPhoto = uploadedBirdPhoto ? null : getDefaultBirdPhotoAttachment();
|
||||
const birdPhotoCid = uploadedBirdPhoto ? 'bird-photo' : defaultBirdPhoto ? defaultBirdPhoto.cid : '';
|
||||
|
||||
if (logoAttachment) {
|
||||
attachments.push(logoAttachment);
|
||||
}
|
||||
|
||||
if (uploadedBirdPhoto) {
|
||||
attachments.push({
|
||||
filename: `${reminder.name.replace(/[^a-z0-9_-]+/gi, '-').toLowerCase() || 'bird'}-photo`,
|
||||
content: uploadedBirdPhoto.content,
|
||||
contentType: uploadedBirdPhoto.contentType,
|
||||
cid: birdPhotoCid,
|
||||
contentDisposition: 'inline',
|
||||
});
|
||||
} else if (defaultBirdPhoto) {
|
||||
attachments.push(defaultBirdPhoto);
|
||||
}
|
||||
|
||||
const birdPhotoHtml = birdPhotoCid
|
||||
? `<img src="cid:${birdPhotoCid}" alt="${escapeHtml(reminder.name)}" style="display: block; width: 148px; height: 148px; border-radius: 28px; object-fit: cover; border: 4px solid #fff8ef; box-shadow: 0 14px 30px rgba(38, 51, 49, 0.18);" />`
|
||||
: `<div style="display: grid; place-items: center; width: 148px; height: 148px; border-radius: 28px; background: linear-gradient(135deg, #fff8ef, #eaf7ef); border: 4px solid #fff8ef; box-shadow: 0 14px 30px rgba(38, 51, 49, 0.18); color: #238a5a; font-size: 64px; font-weight: 800;">${escapeHtml(reminder.name.slice(0, 1).toUpperCase())}</div>`;
|
||||
const lines = [
|
||||
copy.headline,
|
||||
'',
|
||||
@@ -2071,43 +2020,18 @@ const sendBirdMilestoneReminderNotification = async ({
|
||||
bcc: uniqueRecipients,
|
||||
subject: copy.subject,
|
||||
text: lines.join('\n'),
|
||||
attachments,
|
||||
html: `
|
||||
<div style="margin: 0; padding: 28px; background-color: #fef5e7; background-image: url('${trackPatternDataUrl}'), radial-gradient(circle at 14% 10%, rgba(222, 124, 58, 0.24), transparent 22%), radial-gradient(circle at 82% 12%, rgba(53, 136, 110, 0.22), transparent 20%), linear-gradient(180deg, #fef5e7 0%, #e9ddba 46%, #d9eadf 100%); background-repeat: repeat, no-repeat, no-repeat, no-repeat; font-family: Arial, sans-serif; color: #1f2a2a; line-height: 1.6;">
|
||||
<div style="max-width: 680px; margin: 0 auto 18px;">
|
||||
<img src="${trackPatternDataUrl}" alt="" style="display: block; width: 100%; max-width: 680px; height: auto; border-radius: 26px;" />
|
||||
</div>
|
||||
<div style="max-width: 680px; margin: 0 auto; overflow: hidden; border-radius: 30px; background-color: #e7f4e9; background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.44), transparent 42%), linear-gradient(180deg, rgba(235, 247, 237, 0.98), rgba(211, 235, 220, 0.96)); border: 1px solid rgba(53, 129, 98, 0.34); box-shadow: 0 22px 44px rgba(89, 48, 42, 0.14);">
|
||||
<div style="padding: 24px 28px; background-color: #edf8ef; background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.46), transparent 46%), linear-gradient(180deg, rgba(242, 250, 243, 0.98), rgba(220, 241, 226, 0.94)); border-bottom: 1px solid rgba(53, 129, 98, 0.18);">
|
||||
${
|
||||
logoAttachment
|
||||
? '<img src="cid:flockpal-logo" alt="FlockPal" style="display: block; width: 180px; max-width: 72%; height: auto;" />'
|
||||
: '<strong style="display: block; color: #238a5a; font-size: 22px;">FlockPal</strong>'
|
||||
}
|
||||
</div>
|
||||
<div style="padding: 30px 28px;">
|
||||
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="border-collapse: collapse;">
|
||||
<tr>
|
||||
<td style="vertical-align: top; padding: 0 24px 20px 0; width: 160px;">
|
||||
${birdPhotoHtml}
|
||||
</td>
|
||||
<td style="vertical-align: top; padding: 0 0 20px;">
|
||||
<h1 style="margin: 0 0 12px; color: #1f2a2a; font-size: 30px; line-height: 1.12;">${escapeHtml(copy.headline)}</h1>
|
||||
<p style="margin: 0; color: #63562d; font-size: 17px;">${escapeHtml(copy.intro)}</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p style="margin: 4px 0 18px; font-size: 16px;">${escapeHtml(copy.body)}</p>
|
||||
<p style="margin: 0;">
|
||||
<a href="${frontendBaseUrl}" style="display: inline-block; padding: 12px 18px; border-radius: 999px; background: linear-gradient(135deg, #238a5a, #2f8f98); color: #ffffff; text-decoration: none; font-weight: 700; box-shadow: 0 12px 24px rgba(72, 97, 62, 0.16);">Open FlockPal</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div style="max-width: 680px; margin: 18px auto 0;">
|
||||
<img src="${trackPatternDataUrl}" alt="" style="display: block; width: 100%; max-width: 680px; height: auto; border-radius: 26px;" />
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
...await buildEmailLayout({
|
||||
bird: reminder,
|
||||
eyebrow: copy.eyebrow,
|
||||
headline: copy.headline,
|
||||
preheader: copy.intro,
|
||||
contentHtml: `<p style="margin:0 0 16px;font-size:16px;">${escapeHtml(copy.intro)}</p>
|
||||
<p>${escapeHtml(copy.body)}</p>
|
||||
<p><strong>${escapeHtml(reminder.name)}</strong> · ${escapeHtml(reminder.species)}</p>
|
||||
<p>${escapeHtml(`${copy.eventName}: ${copy.milestoneLabel}`)}</p>
|
||||
`,
|
||||
action: { url: frontendBaseUrl, label: 'Open FlockPal' },
|
||||
}),
|
||||
});
|
||||
|
||||
return { delivered: true };
|
||||
@@ -2127,35 +2051,6 @@ const sendMedicationReminderNotification = async ({
|
||||
}
|
||||
|
||||
const copy = buildMedicationReminderCopy(reminder);
|
||||
const attachments: NonNullable<SendMailOptions['attachments']> = [];
|
||||
const logoAttachment = getFlockPalLogoAttachment();
|
||||
const trackPatternDataUrl = getEmailTrackPatternDataUrl();
|
||||
const uploadedBirdPhoto = reminder.photo_data_url ? parseDataImage(reminder.photo_data_url) : null;
|
||||
const defaultBirdPhoto = uploadedBirdPhoto ? null : getDefaultBirdPhotoAttachment();
|
||||
const birdPhotoCid = uploadedBirdPhoto ? 'bird-photo' : defaultBirdPhoto ? defaultBirdPhoto.cid : '';
|
||||
|
||||
if (logoAttachment) {
|
||||
attachments.push(logoAttachment);
|
||||
}
|
||||
|
||||
if (uploadedBirdPhoto) {
|
||||
attachments.push({
|
||||
filename: `${reminder.name.replace(/[^a-z0-9_-]+/gi, '-').toLowerCase() || 'bird'}-photo`,
|
||||
content: uploadedBirdPhoto.content,
|
||||
contentType: uploadedBirdPhoto.contentType,
|
||||
cid: birdPhotoCid,
|
||||
contentDisposition: 'inline',
|
||||
});
|
||||
} else if (defaultBirdPhoto) {
|
||||
attachments.push(defaultBirdPhoto);
|
||||
}
|
||||
|
||||
const birdPhotoHtml = birdPhotoCid
|
||||
? `<img src="cid:${birdPhotoCid}" alt="${escapeHtml(reminder.name)}" style="display: block; width: 148px; height: 148px; border-radius: 28px; object-fit: cover; border: 4px solid #fff8ef; box-shadow: 0 14px 30px rgba(38, 51, 49, 0.18);" />`
|
||||
: `<div style="display: grid; place-items: center; width: 148px; height: 148px; border-radius: 28px; background: linear-gradient(135deg, #fff8ef, #eaf7ef); border: 4px solid #fff8ef; box-shadow: 0 14px 30px rgba(38, 51, 49, 0.18); color: #238a5a; font-size: 64px; font-weight: 800;">${escapeHtml(reminder.name.slice(0, 1).toUpperCase())}</div>`;
|
||||
const medicationNotesHtml = reminder.medication_notes
|
||||
? `<p style="margin: 0 0 18px; font-size: 15px; color: #63562d;"><strong>Medication notes:</strong> ${escapeHtml(reminder.medication_notes)}</p>`
|
||||
: '';
|
||||
const lines = [
|
||||
copy.headline,
|
||||
'',
|
||||
@@ -2182,46 +2077,18 @@ const sendMedicationReminderNotification = async ({
|
||||
bcc: uniqueRecipients,
|
||||
subject: copy.subject,
|
||||
text: lines.join('\n'),
|
||||
attachments,
|
||||
html: `
|
||||
<div style="margin: 0; padding: 28px; background-color: #fef5e7; background-image: url('${trackPatternDataUrl}'), radial-gradient(circle at 14% 10%, rgba(222, 124, 58, 0.24), transparent 22%), radial-gradient(circle at 82% 12%, rgba(53, 136, 110, 0.22), transparent 20%), linear-gradient(180deg, #fef5e7 0%, #e9ddba 46%, #d9eadf 100%); background-repeat: repeat, no-repeat, no-repeat, no-repeat; font-family: Arial, sans-serif; color: #1f2a2a; line-height: 1.6;">
|
||||
<div style="max-width: 680px; margin: 0 auto 18px;">
|
||||
<img src="${trackPatternDataUrl}" alt="" style="display: block; width: 100%; max-width: 680px; height: auto; border-radius: 26px;" />
|
||||
</div>
|
||||
<div style="max-width: 680px; margin: 0 auto; overflow: hidden; border-radius: 30px; background-color: #e7f4e9; background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.44), transparent 42%), linear-gradient(180deg, rgba(235, 247, 237, 0.98), rgba(211, 235, 220, 0.96)); border: 1px solid rgba(53, 129, 98, 0.34); box-shadow: 0 22px 44px rgba(89, 48, 42, 0.14);">
|
||||
<div style="padding: 24px 28px; background-color: #edf8ef; background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.46), transparent 46%), linear-gradient(180deg, rgba(242, 250, 243, 0.98), rgba(220, 241, 226, 0.94)); border-bottom: 1px solid rgba(53, 129, 98, 0.18);">
|
||||
${
|
||||
logoAttachment
|
||||
? '<img src="cid:flockpal-logo" alt="FlockPal" style="display: block; width: 180px; max-width: 72%; height: auto;" />'
|
||||
: '<strong style="display: block; color: #238a5a; font-size: 22px;">FlockPal</strong>'
|
||||
}
|
||||
</div>
|
||||
<div style="padding: 30px 28px;">
|
||||
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="border-collapse: collapse;">
|
||||
<tr>
|
||||
<td style="vertical-align: top; padding: 0 24px 20px 0; width: 160px;">
|
||||
${birdPhotoHtml}
|
||||
</td>
|
||||
<td style="vertical-align: top; padding: 0 0 20px;">
|
||||
<p style="margin: 0 0 8px; color: #238a5a; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em;">${escapeHtml(copy.eyebrow)}</p>
|
||||
<h1 style="margin: 0 0 12px; color: #1f2a2a; font-size: 30px; line-height: 1.12;">${escapeHtml(copy.headline)}</h1>
|
||||
<p style="margin: 0; color: #63562d; font-size: 17px;">${escapeHtml(copy.intro)}</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p style="margin: 4px 0 10px; font-size: 16px;">${escapeHtml(copy.body)}</p>
|
||||
<p style="margin: 0 0 18px; font-size: 15px; color: #63562d;"><strong>Schedule:</strong> ${escapeHtml(copy.detailLabel)}</p>
|
||||
${medicationNotesHtml}
|
||||
<p style="margin: 0;">
|
||||
<a href="${frontendBaseUrl}" style="display: inline-block; padding: 12px 18px; border-radius: 999px; background: linear-gradient(135deg, #238a5a, #2f8f98); color: #ffffff; text-decoration: none; font-weight: 700; box-shadow: 0 12px 24px rgba(72, 97, 62, 0.16);">Open FlockPal</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div style="max-width: 680px; margin: 18px auto 0;">
|
||||
<img src="${trackPatternDataUrl}" alt="" style="display: block; width: 100%; max-width: 680px; height: auto; border-radius: 26px;" />
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
...await buildEmailLayout({
|
||||
bird: reminder,
|
||||
eyebrow: copy.eyebrow,
|
||||
headline: copy.headline,
|
||||
preheader: copy.intro,
|
||||
contentHtml: `<p style="margin:0 0 16px;font-size:16px;">${escapeHtml(copy.intro)}</p>
|
||||
<p>${escapeHtml(copy.body)}</p>
|
||||
<p><strong>${escapeHtml(reminder.name)}</strong> · ${escapeHtml(reminder.species)}</p>
|
||||
<p>${escapeHtml(copy.detailLabel)}</p>
|
||||
${reminder.medication_notes ? `<p><strong>Medication notes:</strong> ${escapeHtml(reminder.medication_notes)}</p>` : ''}`,
|
||||
action: { url: frontendBaseUrl, label: 'Open FlockPal' },
|
||||
}),
|
||||
});
|
||||
|
||||
return { delivered: true };
|
||||
@@ -2277,9 +2144,7 @@ export const sendWeightReminderNotification = async (reminders: WeightReminder[]
|
||||
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>`,
|
||||
...await buildWeightReminderEmail(reminders, frontendBaseUrl),
|
||||
});
|
||||
return result.accepted.length > 0;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user