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<boolean> (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<boolean> (true on success, false on empty/error). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2959,16 +2959,20 @@ export async function sendTeamMentorIntroductionEmail(
|
||||
projectTitle: string,
|
||||
projectId: string,
|
||||
mentors: { name: string | null; email: string }[],
|
||||
): Promise<void> {
|
||||
teammates?: { name: string | null; email: string }[],
|
||||
customNote?: string,
|
||||
): Promise<boolean> {
|
||||
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<void> {
|
||||
projects: { id: string; title: string; teamMembers?: { name: string | null; email: string }[] }[],
|
||||
customNote?: string,
|
||||
): Promise<boolean> {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user