Skip to content

Email preferences are defined in schema but not respected in email sending logic #39

@hetrakholiya11

Description

@hetrakholiya11

Team 101

Problem:
The User model includes an emailPreferences field in the Prisma schema, but the email sending logic does not check or respect these preferences before sending emails.

What’s happening:
In the database schema, users have configurable email preference flags such as:

  • welcomeEmail
  • streakReminder
  • streakBroken
  • weeklySummary

However, functions like:

  • sendStreakReminder
  • sendStreakBrokenNotification
  • sendWeeklySummary
  • sendWelcomeEmail

send emails without checking whether the user has opted out of that specific email type.

Why this is important:
This results in users receiving emails even if they have disabled that notification type in their preferences.

From a product perspective:

  • This breaks expected user behavior
  • Makes the emailPreferences field effectively unused
  • Reduces trust in notification controls
  • Creates an incomplete feature implementation

Expected behavior:
Before sending any email, the system should check the user's emailPreferences field and only send the email if the relevant preference is enabled.

Suggested improvement:

  • Fetch user.emailPreferences before sending emails
  • Gate each email type based on its corresponding preference flag
  • Skip sending the email if the preference is set to false
  • Optionally pass preferences into the email service to avoid extra DB queries

This would complete the existing email preference infrastructure and make the notification system behave as intended.

I would be happy to work on implementing this if assigned.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions