feat: certification rules, content sanitization, handle draft course updates and reset content, better redis logging

This commit is contained in:
Rotimi Best
2026-03-30 08:24:55 +01:00
parent ff2ad59377
commit 5a8f50f67b
131 changed files with 5643 additions and 2134 deletions
@@ -0,0 +1,33 @@
import * as z from 'zod';
import { defineEmail } from '../send';
import { getDefaultTemplate } from '../templates';
export const studentCourseCompletionEmail = defineEmail({
id: 'studentCourseCompletion',
subject: 'Congratulations — you completed the course requirements',
schema: z.object({
orgName: z.string().min(1),
courseName: z.string().min(1),
studentName: z.string().min(1),
certificateUrl: z.string().url(),
customMessage: z.string().nullable().optional()
}),
render: (fields) => {
const customBlock =
fields.customMessage && fields.customMessage.trim().length > 0
? `<div style="margin:16px 0;padding:12px;border-left:3px solid #6366f1;background:#f8fafc;">${fields.customMessage}</div>`
: '';
const content = `
<p>Hi ${fields.studentName},</p>
<p>Congratulations! You have met the completion requirements for <strong>${fields.courseName}</strong>.</p>
${customBlock}
<p><a href="${fields.certificateUrl}" style="display:inline-block;padding:10px 16px;background:#111827;color:#fff;text-decoration:none;border-radius:6px;">View your certificate</a></p>
<p>If the button does not work, copy and paste this link into your browser:<br/><span style="word-break:break-all;">${fields.certificateUrl}</span></p>
<p>Cheers,<br/>${fields.orgName}</p>
`;
return getDefaultTemplate(content);
}
});