Send email notifications for table-backed user events #361

Closed
opened 2026-06-04 00:08:49 -05:00 by Codex · 1 comment
Member

The app has a user_notification_settings table with opt-in flags for user-facing notification events, but the Laravel rebuild should explicitly audit and wire outgoing email notifications for every event represented by those flags.

Some event emails are already implemented, including friend_added_you, mentioned_in_blog_entry, and mentioned_in_blog_entry_comment. This issue tracks confirming those remain covered while implementing or restoring the missing table-backed notification emails for profile comments, game comments, game-list comments, and previously-participated site-news/blog comment threads.

Deferred review-comment scope

The comment_on_your_review flag is intentionally deferred for this issue. The current Laravel rebuild does not have a rebuilt review-comment model/controller/event source to dispatch from, so review-owner comment email dispatch should be handled by a follow-up issue when review comments themselves are rebuilt. This issue still audits the flag and keeps the setting available, but does not create a new review-comment feature.

Scope

  • Audit every user_notification_settings event flag:
    • comment_on_your_profile
    • previously_left_comment_on_game
    • comment_for_game_on_list
    • comment_on_your_review (deferred until a rebuilt review-comment source exists)
    • previously_left_comment_on_review
    • friend_added_you
    • mentioned_in_blog_entry
    • mentioned_in_blog_entry_comment
  • Add or confirm Laravel notification classes/mail content for each supported event source.
  • Wire notification dispatch into the real event sources for profile comments, game comments, friend adds, blog mentions, and public site-news/blog comment participation.
  • Respect each recipient's Y/N preference before sending.
  • Avoid duplicate emails when a single action matches multiple notification rules for the same recipient.
  • Keep account/security emails such as password reset and email verification outside these opt-in notification preferences.
  • Keep notification copy consistent with existing app tone and include safe links back to the relevant page or content.
  • Include the unsubscribe-all URL in optional event emails.

Acceptance Criteria

  • Users who opt in to a notification setting receive an email when the matching supported event occurs.
  • Users who opt out, have no notification settings row, are deleted, or are otherwise unavailable do not receive optional event emails.
  • friend_added_you, mentioned_in_blog_entry, and mentioned_in_blog_entry_comment continue to work and remain covered by regression tests.
  • Profile comment notifications are sent only to the profile owner when comment_on_your_profile is enabled.
  • Game comment notifications cover users who previously commented on the same game when previously_left_comment_on_game is enabled.
  • Game-list comment notifications cover users who have that game on their list when comment_for_game_on_list is enabled.
  • Review comment owner notifications for comment_on_your_review are deferred until a rebuilt review-comment event source exists.
  • Previously-participated site-news/blog comment notifications are sent when previously_left_comment_on_review is enabled.
  • Notification dispatch is idempotent enough to avoid sending multiple emails to the same recipient for one user action.
  • Required account/security emails are not blocked by optional notification settings.

Test Coverage Required

  • Feature tests using Notification::fake() for each implemented event, proving opt-in recipients are notified and opt-out recipients are not.
  • Regression tests for existing friend-added and blog-mention notifications.
  • Tests covering missing notification settings rows and deleted/unavailable recipients.
  • Tests confirming duplicate recipient rules do not send duplicate notifications for one action.
  • Tests confirming users do not receive emails for their own triggering actions where applicable.
  • Tests confirming password reset and email verification notifications remain unaffected by optional notification preferences.
  • Run the focused notification/comment/friend/blog tests, then run vendor/bin/pint --dirty before closing the issue.

Progress Checklist

  • user_notification_settings table exists with per-event Y/N flags
  • Settings UI can toggle the current notification flags
  • friend_added_you notification dispatch exists
  • Blog entry mention notification dispatch exists
  • Blog entry comment mention notification dispatch exists
  • Audit current profile, game, review, and blog comment event sources
  • Add missing notification classes/mail content for supported table-backed events
  • Wire profile comment email dispatch
  • Wire game comment email dispatch for previous commenters
  • Wire game-list comment email dispatch where supported by rebuilt data
  • Defer review comment owner email dispatch until a rebuilt review-comment source exists
  • Wire previously-participated site-news/blog comment email dispatch where supported by rebuilt data
  • Add duplicate-recipient protection for overlapping notification rules
  • Add or update focused notification tests
  • Confirm optional notification preferences do not affect required account/security emails
The app has a `user_notification_settings` table with opt-in flags for user-facing notification events, but the Laravel rebuild should explicitly audit and wire outgoing email notifications for every event represented by those flags. Some event emails are already implemented, including `friend_added_you`, `mentioned_in_blog_entry`, and `mentioned_in_blog_entry_comment`. This issue tracks confirming those remain covered while implementing or restoring the missing table-backed notification emails for profile comments, game comments, game-list comments, and previously-participated site-news/blog comment threads. ## Deferred review-comment scope The `comment_on_your_review` flag is intentionally deferred for this issue. The current Laravel rebuild does not have a rebuilt review-comment model/controller/event source to dispatch from, so review-owner comment email dispatch should be handled by a follow-up issue when review comments themselves are rebuilt. This issue still audits the flag and keeps the setting available, but does not create a new review-comment feature. ## Scope - Audit every `user_notification_settings` event flag: - `comment_on_your_profile` - `previously_left_comment_on_game` - `comment_for_game_on_list` - `comment_on_your_review` (deferred until a rebuilt review-comment source exists) - `previously_left_comment_on_review` - `friend_added_you` - `mentioned_in_blog_entry` - `mentioned_in_blog_entry_comment` - Add or confirm Laravel notification classes/mail content for each supported event source. - Wire notification dispatch into the real event sources for profile comments, game comments, friend adds, blog mentions, and public site-news/blog comment participation. - Respect each recipient's `Y/N` preference before sending. - Avoid duplicate emails when a single action matches multiple notification rules for the same recipient. - Keep account/security emails such as password reset and email verification outside these opt-in notification preferences. - Keep notification copy consistent with existing app tone and include safe links back to the relevant page or content. - Include the unsubscribe-all URL in optional event emails. ## Acceptance Criteria - Users who opt in to a notification setting receive an email when the matching supported event occurs. - Users who opt out, have no notification settings row, are deleted, or are otherwise unavailable do not receive optional event emails. - `friend_added_you`, `mentioned_in_blog_entry`, and `mentioned_in_blog_entry_comment` continue to work and remain covered by regression tests. - Profile comment notifications are sent only to the profile owner when `comment_on_your_profile` is enabled. - Game comment notifications cover users who previously commented on the same game when `previously_left_comment_on_game` is enabled. - Game-list comment notifications cover users who have that game on their list when `comment_for_game_on_list` is enabled. - Review comment owner notifications for `comment_on_your_review` are deferred until a rebuilt review-comment event source exists. - Previously-participated site-news/blog comment notifications are sent when `previously_left_comment_on_review` is enabled. - Notification dispatch is idempotent enough to avoid sending multiple emails to the same recipient for one user action. - Required account/security emails are not blocked by optional notification settings. ## Test Coverage Required - Feature tests using `Notification::fake()` for each implemented event, proving opt-in recipients are notified and opt-out recipients are not. - Regression tests for existing friend-added and blog-mention notifications. - Tests covering missing notification settings rows and deleted/unavailable recipients. - Tests confirming duplicate recipient rules do not send duplicate notifications for one action. - Tests confirming users do not receive emails for their own triggering actions where applicable. - Tests confirming password reset and email verification notifications remain unaffected by optional notification preferences. - Run the focused notification/comment/friend/blog tests, then run `vendor/bin/pint --dirty` before closing the issue. ## Progress Checklist - [x] `user_notification_settings` table exists with per-event `Y/N` flags - [x] Settings UI can toggle the current notification flags - [x] `friend_added_you` notification dispatch exists - [x] Blog entry mention notification dispatch exists - [x] Blog entry comment mention notification dispatch exists - [x] Audit current profile, game, review, and blog comment event sources - [x] Add missing notification classes/mail content for supported table-backed events - [x] Wire profile comment email dispatch - [x] Wire game comment email dispatch for previous commenters - [x] Wire game-list comment email dispatch where supported by rebuilt data - [x] Defer review comment owner email dispatch until a rebuilt review-comment source exists - [x] Wire previously-participated site-news/blog comment email dispatch where supported by rebuilt data - [x] Add duplicate-recipient protection for overlapping notification rules - [x] Add or update focused notification tests - [x] Confirm optional notification preferences do not affect required account/security emails
jimmyb self-assigned this 2026-06-10 11:34:03 -05:00
Author
Member

Implemented and pushed in 6b1f86f (Wire table-backed notification emails).

What changed:

  • Added optional notification mail classes for profile comments, previous game commenters, game-list owners, and previously-participated public site-news/blog comment threads.
  • Added a shared dispatcher that enforces active users only, live user_notification_settings rows only, matching Y flags, actor/self exclusion, and duplicate-recipient suppression for overlapping rules.
  • Wired dispatch into profile, game, and blog comment creation.
  • Kept existing friend-added and blog mention notifications in place; blog comment mentions now report notified users so participant-thread mail does not duplicate mention mail.
  • Updated the issue scope to explicitly defer comment_on_your_review owner dispatch until a rebuilt review-comment event source exists.

Verification:

  • php artisan test --compact tests/Feature/OptionalUserNotificationTest.php -> 8 passed, 44 assertions.
  • Focused regression suite for profile/game/blog/friend/unsubscribe behavior -> 92 passed, 825 assertions.
  • vendor/bin/pint --dirty --format agent -> passed.
  • Post-Pint focused rerun -> 8 passed, 44 assertions.
  • git diff --check -> clean.
Implemented and pushed in `6b1f86f` (`Wire table-backed notification emails`). What changed: - Added optional notification mail classes for profile comments, previous game commenters, game-list owners, and previously-participated public site-news/blog comment threads. - Added a shared dispatcher that enforces active users only, live `user_notification_settings` rows only, matching `Y` flags, actor/self exclusion, and duplicate-recipient suppression for overlapping rules. - Wired dispatch into profile, game, and blog comment creation. - Kept existing friend-added and blog mention notifications in place; blog comment mentions now report notified users so participant-thread mail does not duplicate mention mail. - Updated the issue scope to explicitly defer `comment_on_your_review` owner dispatch until a rebuilt review-comment event source exists. Verification: - `php artisan test --compact tests/Feature/OptionalUserNotificationTest.php` -> 8 passed, 44 assertions. - Focused regression suite for profile/game/blog/friend/unsubscribe behavior -> 92 passed, 825 assertions. - `vendor/bin/pint --dirty --format agent` -> passed. - Post-Pint focused rerun -> 8 passed, 44 assertions. - `git diff --check` -> clean.
Codex 2026-06-10 12:17:25 -05:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MyVideoGameList/myvideogamelist.com#361
No description provided.