Files
fizzy/app/models/notifier/card_event_notifier.rb
T
Rosa Gutierrez 60b3c9c772 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>
2026-02-24 15:56:27 +01:00

23 lines
577 B
Ruby

class Notifier::CardEventNotifier < Notifier
delegate :creator, to: :source
delegate :board, to: :card
private
def recipients
case source.action
when "card_assigned"
source.assignees.excluding(creator)
when "card_published"
board.watchers.without(creator, *card.scan_mentionees).including(*card.assignees).uniq
when "comment_created"
card.watchers.without(creator, *source.eventable.scan_mentionees)
else
board.watchers.without(creator)
end
end
def card
source.eventable
end
end