Add email notification on new lesson comment
Notify admins/curators (or configured notificationEmails) when a student leaves a comment under a lesson. New setting notifyOnComment (default on) + toggle in admin settings. Fires only for student comments, not admin/curator replies; comment text is HTML-escaped in the email. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -137,6 +137,31 @@ export async function sendHomeworkSubmittedEmail(
|
||||
}).catch((e) => console.error("[email] sendHomeworkSubmittedEmail:", e));
|
||||
}
|
||||
|
||||
export async function sendCommentNotificationEmail(
|
||||
to: string,
|
||||
recipientName: string,
|
||||
studentName: string,
|
||||
lessonTitle: string,
|
||||
commentText: string,
|
||||
lessonUrl: string
|
||||
) {
|
||||
const school = await getSchoolName();
|
||||
const esc = (t: string) => t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
||||
const preview = commentText.length > 400 ? commentText.slice(0, 400) + "…" : commentText;
|
||||
await getResend().emails.send({
|
||||
from: FROM,
|
||||
to,
|
||||
subject: `Новый комментарий под уроком — ${lessonTitle}`,
|
||||
html: base(`
|
||||
<p ${p}>Привет${recipientName ? `, ${esc(recipientName)}` : ""}!</p>
|
||||
<p ${p}><strong>${esc(studentName)}</strong> оставил комментарий под уроком <strong>«${lessonTitle}»</strong>:</p>
|
||||
${quote(esc(preview))}
|
||||
<p ${pLast}>Открыть урок и ответить:</p>
|
||||
${btn(lessonUrl, "Открыть урок")}
|
||||
`, school),
|
||||
}).catch((e) => console.error("[email] sendCommentNotificationEmail:", e));
|
||||
}
|
||||
|
||||
export async function sendFeedbackReceivedEmail(
|
||||
to: string,
|
||||
studentName: string,
|
||||
|
||||
Reference in New Issue
Block a user