fix(audit): wire 6 missing email subject overrides (R2-H14)
Admin-editable subject overrides at /admin/email-templates were no-ops for 6 of 8 templates — only portal_activation and portal_reset called loadSubjectOverride. Added a shared resolveSubject() helper and wired it into the missing senders: - crm_invite + portal_invite_resend (crm-invite.service.ts) - inquiry_client_confirmation (email worker via portId on job payload) - inquiry_sales_notification (email worker via portId on job payload) - residential_inquiry_client_confirmation (residential-inquiries route) - residential_inquiry_sales_alert (residential-inquiries route) The inquiry email worker payloads now carry portId + portName so the worker can resolve the per-port override; producers in inquiry- notifications.service.ts pass them through. 1175/1175 vitest passing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -18,31 +18,48 @@ export const emailWorker = new Worker(
|
||||
break;
|
||||
}
|
||||
case 'send-inquiry-confirmation': {
|
||||
const { to, firstName, mooringNumber, contactEmail } = job.data as {
|
||||
const { to, firstName, mooringNumber, contactEmail, portId, portName } = job.data as {
|
||||
to: string;
|
||||
firstName: string;
|
||||
mooringNumber: string | null;
|
||||
contactEmail: string;
|
||||
portId?: string;
|
||||
portName?: string;
|
||||
};
|
||||
const { inquiryClientConfirmation } =
|
||||
await import('@/lib/email/templates/inquiry-client-confirmation');
|
||||
const { sendEmail } = await import('@/lib/email/index');
|
||||
const { resolveSubject } = await import('@/lib/email/resolve-subject');
|
||||
const email = inquiryClientConfirmation({ firstName, mooringNumber, contactEmail });
|
||||
await sendEmail(to, email.subject, email.html, undefined, email.text);
|
||||
const subject = await resolveSubject({
|
||||
key: 'inquiry_client_confirmation',
|
||||
portId,
|
||||
fallback: email.subject,
|
||||
tokens: {
|
||||
portName: portName ?? 'Port Nimara',
|
||||
recipientName: firstName,
|
||||
mooringNumber: mooringNumber ?? '',
|
||||
},
|
||||
});
|
||||
await sendEmail(to, subject, email.html, undefined, email.text, portId);
|
||||
break;
|
||||
}
|
||||
case 'send-inquiry-sales-notification': {
|
||||
const { to, fullName, email, phone, mooringNumber, crmUrl } = job.data as {
|
||||
to: string;
|
||||
fullName: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
mooringNumber: string | null;
|
||||
crmUrl: string;
|
||||
};
|
||||
const { to, fullName, email, phone, mooringNumber, crmUrl, portId, portName } =
|
||||
job.data as {
|
||||
to: string;
|
||||
fullName: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
mooringNumber: string | null;
|
||||
crmUrl: string;
|
||||
portId?: string;
|
||||
portName?: string;
|
||||
};
|
||||
const { inquirySalesNotification } =
|
||||
await import('@/lib/email/templates/inquiry-sales-notification');
|
||||
const { sendEmail } = await import('@/lib/email/index');
|
||||
const { resolveSubject } = await import('@/lib/email/resolve-subject');
|
||||
const notification = inquirySalesNotification({
|
||||
fullName,
|
||||
email,
|
||||
@@ -50,7 +67,18 @@ export const emailWorker = new Worker(
|
||||
mooringNumber,
|
||||
crmUrl,
|
||||
});
|
||||
await sendEmail(to, notification.subject, notification.html, undefined, notification.text);
|
||||
const subject = await resolveSubject({
|
||||
key: 'inquiry_sales_notification',
|
||||
portId,
|
||||
fallback: notification.subject,
|
||||
tokens: {
|
||||
portName: portName ?? 'Port Nimara',
|
||||
clientName: fullName,
|
||||
mooringNumber: mooringNumber ?? '',
|
||||
email,
|
||||
},
|
||||
});
|
||||
await sendEmail(to, subject, notification.html, undefined, notification.text, portId);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user