Skip to content

Add flag-related email notifications for flagged player and offline opponent#668

Draft
Copilot wants to merge 6 commits into
masterfrom
copilot/send-email-notification-flagged-users
Draft

Add flag-related email notifications for flagged player and offline opponent#668
Copilot wants to merge 6 commits into
masterfrom
copilot/send-email-notification-flagged-users

Conversation

Copilot AI commented May 17, 2026

Copy link
Copy Markdown
Contributor

This change addresses missing player feedback when a user loses on time (flags). It now covers both players:

  • the player who flagged receives a direct notification, and

  • the opponent can receive an offline notification (after being offline long enough), with a user setting to enable/disable it.

  • Flag event now emails the flagged player

    • PlayerVsPlayerGameService.flagByColor(...) triggers a mail notification after a successful flag update.
    • The recipient is resolved from the flagged player's email; if no email is available, this notification is skipped.
  • Flag event can now email the other player when offline

    • Added offline-threshold-based opponent notification logic (aligned with existing offline notification behavior).
    • Added MailService.sendOpponentFlaggedWhileOffline(...) and a new template:
      • mail_templates/opponent_flagged_while_offline.html
  • New notification preference in /user/settings

    • Added a checkbox for opponent-flagged-offline notifications.
    • Wired end-to-end through notifications API/DTO/DAO and persistence.
  • Data model and migration updates

    • Added email_notification_enabled_opponent_flagged to user notification settings.
    • Updated Liquibase changelogs accordingly.
  • Updated existing flagged mail API/template

    • MailService.sendUserFlaggedNotification(...) accepts recipient email and sends directly to the flagged player.
    • mail_templates/user_flagged_notification.html is user-facing and includes username, game ID, and game link.
  • Template and settings coverage

    • Updated MailRendererTest for user_flagged_notification.
    • Added MailRendererTest case for opponent_flagged_while_offline.
    • Updated UserDaoServiceTest assertions for the new notification setting.
mailService.sendUserFlaggedNotification(
    recipient = email,
    gameId = gameId,
    username = userCache.fetchUsernameOrDefault(userId),
)

Copilot AI linked an issue May 17, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add email notification for flagged users Add admin email notification when a player flags on time May 17, 2026
Copilot finished work on behalf of benckx May 17, 2026 19:07
Copilot AI requested a review from benckx May 17, 2026 19:07

@benckx benckx left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot it's not the admin that should be notified but the player who lost by flagging

@benckx

benckx commented May 17, 2026

Copy link
Copy Markdown
Owner

@copilot actually the other player too. But they have to be offline for a while (like the other mail notifications). And there must be a checkbox in the /user/settings to enable or disable this notification.

Copilot AI commented May 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot it's not the admin that should be notified but the player who lost by flagging

Updated in commit 3939ca0: flagged notifications are now sent to the player who flagged (using their email), not to admin.

Copilot AI changed the title Add admin email notification when a player flags on time Add email notification to the flagged player when they lose on time May 17, 2026
Copilot finished work on behalf of benckx May 17, 2026 21:14
Copilot AI requested a review from benckx May 17, 2026 21:14

Copilot AI commented May 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot actually the other player too. But they have to be offline for a while (like the other mail notifications). And there must be a checkbox in the /user/settings to enable or disable this notifi...

Implemented in commit 781ec00: the other player is now notified too, but only when they have been offline long enough, and a new /user/settings checkbox controls this (opponent flagged while offline). Screenshot: /tmp/flagged-notification-setting.png

Copilot AI changed the title Add email notification to the flagged player when they lose on time Add flag-related email notifications for flagged player and offline opponent May 17, 2026
Copilot finished work on behalf of benckx May 17, 2026 21:24
@benckx

benckx commented Jun 4, 2026

Copy link
Copy Markdown
Owner

@copilot resolve the merge conflicts in this pull request

Copilot finished work on behalf of benckx June 4, 2026 06:39
@benckx

benckx commented Jun 7, 2026

Copy link
Copy Markdown
Owner

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Done in commit e04b346: merged latest origin/master into this PR branch and resolved the Liquibase changelog conflicts.

Copilot finished work on behalf of benckx June 7, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Send email notification when users has flagged

2 participants