Skip to content

Conversation

fetchfern
Copy link
Contributor

@fetchfern fetchfern commented Sep 4, 2025

This adds an email notification system with user preferences, email templates and an email delivery queue, extending the existing notifications table & functionality. It's extensible to multiple delivery channels (now there's just 'email').

notifications_deliveries: the actual queue. Values are inserted in the same transaction as the insert into notifications (outbox pattern). A poll-based queue worker processes item in the queue with support for concurrent workers and delivery priorities.

Because all emails are implemented via notifications this requires every email type to have a matching notification type. Since we don't want to show all these new notifications types on the website, the notifications_types table has a expose_in_site_notifications column.

Templates are housed in notifications_templates, have a URL to fetch the HTML body from (so that the frontend team can use vue-email and write email templates within the frontend) and a plain-text fallback.

There's a route for other services to issue notifications as well—POST /_internal/external_notifications. It is guarded by X-External-Notification-Key/LABRINTH_EXTERNAL_NOTIFICATION_KEY. The situation with authentication keys on Labrinth is getting quite messy, lots of random keys specified via environment variables. Perhaps worth looking into storing encrypted keys with specific scopes in the database at some point?

Further PRs will add:

  • Hooking current emails into this system. Actually will entirely remove the previous send_email function and move them to notifications within this PR.
  • More notification types.
  • Routes for the servers backend to issue notifications. Also done in this PR

@fetchfern fetchfern marked this pull request as draft September 4, 2025 13:37
@fetchfern fetchfern marked this pull request as ready for review September 8, 2025 15:35
@fetchfern fetchfern changed the title Email notification system [DO NOT MERGE] Email notification system Sep 8, 2025
@fetchfern
Copy link
Contributor Author

Have fully removed the old email functionality. Waiting on approval for current email messages + prod deployments of email templates on modrinth.com/mail before merge.

@fetchfern fetchfern requested review from AlexTMjugador and removed request for AlexTMjugador September 8, 2025 15:37
@fetchfern fetchfern mentioned this pull request Sep 10, 2025
4 tasks
Copy link
Contributor

@Gaming32 Gaming32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite a bit of feedback on this one, though granted some of them are smaller and more nitpicky.

fetchfern and others added 4 commits September 12, 2025 15:10
Co-authored-by: Josiah Glosson <soujournme@gmail.com>
Signed-off-by: François-Xavier Talbot <108630700+fetchfern@users.noreply.github.com>
Co-authored-by: Josiah Glosson <soujournme@gmail.com>
Signed-off-by: François-Xavier Talbot <108630700+fetchfern@users.noreply.github.com>
Co-authored-by: Josiah Glosson <soujournme@gmail.com>
Signed-off-by: François-Xavier Talbot <108630700+fetchfern@users.noreply.github.com>
….sql

Co-authored-by: Josiah Glosson <soujournme@gmail.com>
Signed-off-by: François-Xavier Talbot <108630700+fetchfern@users.noreply.github.com>
@fetchfern fetchfern added this pull request to the merge queue Sep 15, 2025
Merged via the queue into main with commit 902d749 Sep 15, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Relates to Modrinth Backend or API enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants