feat(notifications): per-org member email preferences table (#751)

* feat(notifications): add email notification preferences

Implement the email notification preferences PRD with org-level defaults
and personal opt-outs enforced at the email enqueue chokepoint.

- Add toggle map, profile.settings jsonb, and shouldSendEmail resolver
- Extend profile and organization update APIs with emailNotifications
- Pass preference context through all toggleable email send call sites
- Add Settings > Notifications page with personal and org admin sections

Co-authored-by: Rotimi Best <[email protected]>

* feat(notifications): group email toggles into course, cohort, and enrollment sections

Organize personal and org notification settings into scannable sections
so users can find course- or cohort-related emails quickly.

Co-authored-by: Rotimi Best <[email protected]>

* fix(notifications): use Exercise instead of Quiz in toggle copy

Co-authored-by: Rotimi Best <[email protected]>

* fix(notifications): only mark certification email sent when enqueued

Skip setMemberCertificationEmailSent when notification preferences or
missing Redis prevent the completion email from being queued, so the
email can still send if preferences change later.

Co-authored-by: Rotimi Best <[email protected]>

* fix(notifications): address PR review feedback

- Add EmailPreferenceLookupCache to avoid N+1 settings lookups in batch
  processors and multi-recipient email enqueue paths
- Replace $effect store hydration in notifications settings with onMount
  and explicit sync after save
- Remove thin api email-preferences re-export; import from db queries
- Hide tutor-only personal toggles (newStudent, newSubmission) for students

Co-authored-by: Rotimi Best <[email protected]>

* fix(notifications): hydrate toggles after store load and add profile settings migration

- One-time store hydration via onMount plus guarded effect when profile/org
  load after mount, without clobbering in-progress edits
- Add drizzle migration for profile.settings jsonb column

Co-authored-by: Rotimi Best <[email protected]>

* feat(notifications): add email preferences to LMS settings

Students manage personal email opt-outs from /lms/settings/notifications,
matching the org settings page but scoped to the LMS navigation students use.

Co-authored-by: Rotimi Best <[email protected]>

* feat(notifications): store per-org personal prefs in organizationmember_email_notifications

- Add organizationmember_email_notifications table keyed by organizationmember
- Expose GET/PUT /organization/member/email-notifications for current org member
- Resolve personal email prefs by profileId + organizationId at send time
- Migrate legacy profile.settings.emailNotifications into per-membership rows
- Update org and LMS settings UI to load/save org-scoped member preferences

Co-authored-by: Rotimi Best <[email protected]>

* fix(notifications): address PR review on locales and backfill script

Move profile email-notification backfill out of the migration SQL into
a dedicated db script with dry-run support. Translate personal preference
description strings in all non-English locale files.

Co-authored-by: Rotimi Best <[email protected]>

* fix(i18n): translate notification preference strings in all locales

Complete settings.notifications and settings.tabs.notifications_tab
translations for da, de, es, fr, hi, pl, pt, ru, and vi.

Co-authored-by: Rotimi Best <[email protected]>

---------

Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: Rotimi Best <[email protected]>
This commit is contained in:
Rotimi Best
2026-07-16 10:04:28 +01:00
committed by GitHub
co-authored by Rotimi Best Cursor Agent
parent 9681770270
commit f3d1a885b9
36 changed files with 13197 additions and 475 deletions
@@ -3641,71 +3641,73 @@
"notifications": {
"heading": "Notifications",
"page_title": "Notifications",
"page_subtitle": "Choose which email notifications you receive and, as an admin, which emails your organization sends.",
"page_subtitle": "Choisissez les notifications par e-mail que vous recevez et, en tant qu’administrateur, celles que votre organisation envoie.",
"toggles": {
"courseCompletion": {
"label": "Course completion and certificates",
"description": "Email students when they complete a course and earn a certificate."
"label": "Achèvement du cours et certificats",
"description": "Envoyer un e-mail aux étudiants lorsqu'ils terminent un cours et obtiennent un certificat."
},
"enrollmentWelcome": {
"label": "Enrollment welcome emails",
"description": "Send welcome emails when staff enroll students in courses or cohorts."
"label": "E-mails de bienvenue d'inscription",
"description": "Envoyer des e-mails de bienvenue lorsque le personnel inscrit des étudiants à des cours ou cohortes."
},
"session": {
"label": "Live session reminders and updates",
"description": "Email students before live sessions and when session details change."
"label": "Rappels et mises à jour des sessions en direct",
"description": "Envoyer un e-mail aux étudiants avant les sessions en direct et lors des changements de détails."
},
"cohortReminder": {
"label": "Cohort goal reminders",
"description": "Email students about upcoming or overdue cohort learning goals."
"label": "Rappels d'objectifs de cohorte",
"description": "Envoyer un e-mail aux étudiants concernant les objectifs d'apprentissage à venir ou en retard."
},
"quizAssigned": {
"label": "Exercise assigned",
"description": "Email students when an exercise is assigned or nudged."
"label": "Exercice assigné",
"description": "Envoyer un e-mail aux étudiants lorsqu'un exercice est assigné ou rappelé."
},
"newsfeed": {
"label": "Course announcements and comments",
"description": "Email course members about new posts and comments on the newsfeed."
"label": "Annonces et commentaires du cours",
"description": "Envoyer un e-mail aux membres du cours concernant les nouvelles publications et commentaires."
},
"gradingResult": {
"label": "Grading results",
"description": "Email students when their submission is graded or updated."
"label": "Résultats de notation",
"description": "Envoyer un e-mail aux étudiants lorsque leur soumission est notée ou mise à jour."
},
"newSubmission": {
"label": "New submissions to grade",
"description": "Email tutors when a student submits work that needs grading."
"label": "Nouvelles soumissions à noter",
"description": "Envoyer un e-mail aux tuteurs lorsqu'un étudiant soumet un travail à noter."
},
"newStudent": {
"label": "New student joins",
"description": "Email tutors when a student enrolls in a course."
"label": "Nouvel étudiant s'inscrit",
"description": "Envoyer un e-mail aux tuteurs lorsqu'un étudiant s'inscrit à un cours."
}
},
"org": {
"heading": "Organization defaults",
"description": "When disabled here, nobody in your organization receives that email. Members can still opt out of emails you leave enabled.",
"save": "Save organization defaults",
"save_success": "Organization notification defaults saved"
"heading": "Paramètres par défaut de l'organisation",
"description": "Lorsqu'ils sont désactivés ici, personne dans votre organisation ne reçoit cet e-mail. Les membres peuvent toujours se désabonner des e-mails que vous laissez activés.",
"save": "Enregistrer les paramètres par défaut de l'organisation",
"save_success": "Paramètres de notification de l'organisation enregistrés"
},
"personal": {
"heading": "Your email preferences",
"description": "These apply to emails sent to you across every organization you belong to. Your organization may still disable certain emails for everyone.",
"save": "Save personal preferences",
"save_success": "Personal notification preferences saved"
"heading": "Vos préférences e-mail",
"save": "Enregistrer les préférences personnelles",
"save_success": "Préférences de notification personnelles enregistrées",
"description": "Ces préférences s'appliquent aux e-mails qui vous sont envoyés dans cette organisation. Votre organisation peut toujours désactiver certains e-mails pour tout le monde.",
"description_with_org": "Ces préférences s'appliquent aux e-mails qui vous sont envoyés dans {orgName}. Votre organisation peut toujours désactiver certains e-mails pour tout le monde."
},
"sections": {
"enrollment": {
"heading": "Enrollment",
"description": "Welcome emails sent when staff add members to courses or cohorts."
"heading": "Inscription",
"description": "E-mails de bienvenue envoyés lorsque le personnel ajoute des membres à des cours ou cohortes."
},
"cohort": {
"heading": "Cohort",
"description": "Reminders about cohort learning goals and deadlines."
"heading": "Cohorte",
"description": "Rappels concernant les objectifs d'apprentissage et les échéances de la cohorte."
},
"course": {
"heading": "Course",
"description": "Enrollments, submissions, lessons, announcements, and completions in your courses."
"heading": "Cours",
"description": "Inscriptions, soumissions, leçons, annonces et complétions dans vos cours."
}
}
},
"personal_page_subtitle": "Choisissez les notifications par e-mail que vous recevez de ClassroomIO."
}
},
"profileMenu": {