Context
The email preference service in src/services/email-preference.service.ts has a clear preference model, but the default handling and mandatory overrides are split across multiple code paths. This can lead to inconsistent preferences for newly created users and for updates that modify only part of the preference payload.
Problem statement
Standardize how default preferences are created, merged, and enforced so that onboarding and later updates behave consistently and mandatory security notifications always remain deliverable.
Current behavior
- src/services/email-preference.service.ts builds default preferences in one place, but the merge logic for updates and the mandatory override behavior are partially embedded in the service methods.
- New users and existing users can hit slightly different code paths depending on whether preferences exist yet.
Required behavior
- Default preferences should be created and merged in a single, predictable way.
- Mandatory notification types should always bypass user preference opt-outs.
- Preference updates should preserve the expected defaults while honoring explicit user changes.
Constraints
- The change should preserve the current notification categories and API responses.
- Existing preference records should remain valid after the change.
Acceptance criteria
Out of scope
- Reworking the notification taxonomy or introducing a new preferences UI.
- Changing the email delivery infrastructure.
Hints and references
- Review the shared
EmailPreferenceCategories shape and the shouldSendEmail logic for the current precedence rules.
Context
The email preference service in src/services/email-preference.service.ts has a clear preference model, but the default handling and mandatory overrides are split across multiple code paths. This can lead to inconsistent preferences for newly created users and for updates that modify only part of the preference payload.
Problem statement
Standardize how default preferences are created, merged, and enforced so that onboarding and later updates behave consistently and mandatory security notifications always remain deliverable.
Current behavior
Required behavior
Constraints
Acceptance criteria
Out of scope
Hints and references
EmailPreferenceCategoriesshape and theshouldSendEmaillogic for the current precedence rules.