Fix duplicate push notification for mention and comment event

Event notifiers used the `mentionees` DB association to exclude mentioned
users from comment/card notifications. Since mentions are created async
via Mention::CreateJob, a race condition meant the mentionee list could
be empty when the event notification job ran first, causing the user to
receive both a comment and a mention push notification.

Use `scan_mentionees` instead, which scans the rich text body directly
for mentioned users without depending on Mention records existing yet.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Rosa Gutierrez
2026-02-24 11:58:22 +01:00
committed by Rosa Gutierrez
parent 7b93ec35b4
commit 60b3c9c772
4 changed files with 28 additions and 7 deletions
+2 -2
View File
@@ -8,9 +8,9 @@ class Notifier::CardEventNotifier < Notifier
when "card_assigned"
source.assignees.excluding(creator)
when "card_published"
board.watchers.without(creator, *card.mentionees).including(*card.assignees).uniq
board.watchers.without(creator, *card.scan_mentionees).including(*card.assignees).uniq
when "comment_created"
card.watchers.without(creator, *source.eventable.mentionees)
card.watchers.without(creator, *source.eventable.scan_mentionees)
else
board.watchers.without(creator)
end
@@ -3,7 +3,7 @@ class Notifier::CommentEventNotifier < Notifier
private
def recipients
card.watchers.without(creator, *source.eventable.mentionees)
card.watchers.without(creator, *source.eventable.scan_mentionees)
end
def card