diff --git a/src/lib/email.ts b/src/lib/email.ts index c1da83f..5463a94 100644 --- a/src/lib/email.ts +++ b/src/lib/email.ts @@ -2752,6 +2752,80 @@ export async function sendMentorOnboardingEmail(email: string, name: string | nu await sendEmail({ to: email, subject: template.subject, text: template.text, html: template.html }) } +// ============================================================================= +// Per-team mentor assignment (fires every time a mentor is added to a project) +// ============================================================================= + +function getMentorTeamAssignmentTemplate( + name: string, + projectTitle: string, + workspaceUrl: string, +): EmailTemplate { + const subject = `You've been assigned to a new MOPC project: "${projectTitle}"` + const greeting = name ? `Hi ${name},` : 'Hi there,' + const text = [ + greeting, + '', + `You have been assigned as a mentor to the project "${projectTitle}".`, + '', + 'You may have co-mentors on this team — you can collaborate together in the project workspace.', + '', + `Open the workspace: ${workspaceUrl}`, + '', + 'The MOPC team', + ].join('\n') + + const html = ` + + +
+ + + + `.trim() + + return { subject, text, html } +} + +/** + * Send a per-team mentor assignment email. Fires every time a mentor is added + * to a specific project (distinct from the one-time onboarding email). + * Idempotency is enforced at the call site via MentorAssignment.notificationSentAt. + * Never throws — failures are caught and logged. + */ +export async function sendMentorTeamAssignmentEmail( + email: string, + name: string | null, + projectTitle: string, + projectId: string, +): Promise