Commit Graph

23 Commits

Author SHA1 Message Date
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
Rosa Gutierrez 95114b1d67 Fix race condition between concurrent Event and Mention notifier jobs
When concurrent NotifyRecipientsJobs process an Event and a Mention for
the same user+card, Rails' dirty tracking can skip writing source_type
in the UPDATE if it hasn't changed from the stale in-memory value,
leaving source_type and source_id mismatched (e.g. source_type='Event'
with a Mention's source_id, resulting in a nil source).

Force source_type to always be included in the UPDATE via
source_type_will_change! to prevent this.

Here's a sample timeline of this race condition happening in the real
world (with simplified IDs):

Two `NotifyRecipientsJob` involving notification `03fklpu`, same card,
same user, same comment — enqueued within 50ms of each other:

1. Both jobs load notification `03fklpu` — it has source_type='Mention'
   (from a previous job)
2. `EventNotifier` writes at 21:22:36.051: ```sql SET
   source_type='Event', source_id=<event_id>, unread_count=1 ```
3. `source_type` included because it changed ('Mention' → 'Event')
4. `MentionNotifier` writes at 21:22:36.057 (~6ms later): ```sql SET
   source_id=<mention_id>, unread_count=1 ```
5. No `source_type`! It was `'Mention'` when loaded and `'Mention'` is
   what it's setting → not dirty → skipped
6. Final DB state: `source_type='Event'` (from step 2, untouched),
   `source_id=<mention_id>` (from step 3)

`Notification.source` now does `Event.find(<mention_id>) → nil.`

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-16 16:50:46 +01:00
Stanko K.R. 36ee253a1a Stack notifications everywhere
We had client-side notification stacking in the tray since launch, but now we want to stack notifications in the notifications page, in API responses and in email bundles.
2026-02-12 10:29:50 +01:00
Mike Dalessio e0aa1d257e Drop User.system and replace with Account#system_user 2025-11-24 13:23:57 -05:00
Jorge Manrubia b13823305b Always include assignees when notifying of published cards 2025-11-10 13:08:51 +01:00
Jorge Manrubia 03a345609e Baseline replacing collection with board across code 2025-11-05 13:31:54 +01:00
Mike Dalessio 71103400d6 Make sure the schema and schema cache are consistent with reality
There has been a bit of drift between actual schemas in production and
what's implied by the migrations.

And fixed some tests that were relying on everyone always watching.

ref: https://fizzy.37signals.com/5986089/cards/2322
2025-10-14 17:38:08 -04:00
Jason Zimdars f57b6627e7 User needs to be explicity set to watching to receive this notification 2025-09-16 12:58:56 +02:00
Jason Zimdars 9ad813e5d0 Fix misleading test
The access involvement changes exposed that this test wasn't doing what it said it was. For this to be a self-assignment the event creator and assignee need to be the same
2025-09-11 21:33:21 -05:00
Jason Zimdars c4dec29b49 Assignment notifications should always be delivered
- They're effectively @mentions
- This means watching really reflects the UI state: Watching for new cards
2025-09-11 21:21:11 -05:00
Jason Zimdars e68b344cc2 Remove _Everything_ inolvement 2025-09-11 12:34:31 -05:00
Jorge Manrubia 0045e48f70 Don't notify yourself of self-assignments 2025-05-01 12:57:25 +02:00
Jorge Manrubia 40368032f2 Split notifiers for comments and cards
This lets us remove the annoying if to check the card
2025-04-24 15:19:42 +02:00
Jorge Manrubia 54f4bd5144 Generalize event's cards as eventable,add collection
Lots to tidy up but this is working
2025-04-24 12:28:16 +02:00
Jorge Manrubia 2545604659 Add tests 2025-04-23 17:20:04 +02:00
Kevin McConnell 2d0c9d309b All notifiers use same recipients 2025-02-26 10:53:03 +00:00
Kevin McConnell e6fe7f680d Associate Event with Bubble
It's kind of a long way to get from one to the other right now. Every
event belongs to a bubble, so let's link them directly.
2025-01-17 14:40:36 +00:00
Kevin McConnell 782259a678 Events should track published now
Previously when an item was `created`, we'd track the event, update the
summary text, and broadcast the notifications. But now that we have a
draft state, we shold do all of this when it's published instead.
2025-01-15 10:58:00 +00:00
Kevin McConnell df260840ab Simplify test 2025-01-14 13:29:39 +00:00
Kevin McConnell 78b7fe0f3d Fix tests 2025-01-14 13:21:20 +00:00
Kevin McConnell 66d0f29d45 Notify on pop as well
And DRY up some duplication.
2025-01-13 14:21:47 +00:00
Kevin McConnell dc53a39b93 Update notification body 2025-01-13 14:21:47 +00:00
Kevin McConnell 5a56c16029 Add a factory for creating notifications 2025-01-13 14:21:47 +00:00