From 0e221c391673aeee0d877474874dfc9e7f080990 Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 1 Jun 2026 16:29:47 +0200 Subject: [PATCH] feat(email): mentorship senders forward contacts/note, return success sendMentorBulkAssignmentEmail now accepts optional teamMembers per project and a customNote, forwards both to the template, switches to getBaseUrl(), and returns Promise (true on success, false on empty/error). sendTeamMentorIntroductionEmail now accepts optional teammates and customNote, forwards both to the template, switches to getBaseUrl(), and returns Promise (true on success, false on empty/error). Co-Authored-By: Claude Sonnet 4.6 --- src/lib/email.ts | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/lib/email.ts b/src/lib/email.ts index f6c11d5..b437d74 100644 --- a/src/lib/email.ts +++ b/src/lib/email.ts @@ -2959,16 +2959,20 @@ export async function sendTeamMentorIntroductionEmail( projectTitle: string, projectId: string, mentors: { name: string | null; email: string }[], -): Promise { + teammates?: { name: string | null; email: string }[], + customNote?: string, +): Promise { try { - if (mentors.length === 0) return - const baseUrl = (process.env.NEXTAUTH_URL || 'https://monaco-opc.com').replace(/\/$/, '') + if (mentors.length === 0) return false + const baseUrl = getBaseUrl() const workspaceUrl = `${baseUrl}/applicant/mentor` const template = getTeamMentorIntroductionTemplate( recipientName, projectTitle, mentors, workspaceUrl, + teammates, + customNote, ) await sendEmail({ to: recipientEmail, @@ -2976,8 +2980,10 @@ export async function sendTeamMentorIntroductionEmail( text: template.text, html: template.html, }) + return true } catch (error) { console.error('[sendTeamMentorIntroductionEmail] failed', { recipientEmail, projectId, error }) + return false } } @@ -3095,23 +3101,23 @@ export function getMentorBulkAssignmentTemplate( export async function sendMentorBulkAssignmentEmail( email: string, name: string | null, - projects: { id: string; title: string }[], -): Promise { + projects: { id: string; title: string; teamMembers?: { name: string | null; email: string }[] }[], + customNote?: string, +): Promise { try { - if (projects.length === 0) return - const baseUrl = (process.env.NEXTAUTH_URL || 'https://monaco-opc.com').replace(/\/$/, '') + if (projects.length === 0) return false + const baseUrl = getBaseUrl() const enriched = projects.map((p) => ({ title: p.title, url: `${baseUrl}/mentor/workspace/${p.id}`, + teamMembers: p.teamMembers, })) - const template = getMentorBulkAssignmentTemplate( - name || '', - enriched, - `${baseUrl}/mentor`, - ) + const template = getMentorBulkAssignmentTemplate(name || '', enriched, `${baseUrl}/mentor`, customNote) await sendEmail({ to: email, subject: template.subject, text: template.text, html: template.html }) + return true } catch (error) { console.error('[sendMentorBulkAssignmentEmail] failed', { email, error }) + return false } }