PhoenixKit.Notifications.DigestWorker (phoenix_kit v1.7.236)

Copy Markdown View Source

Aggregation engine: sends batched notification summaries for types a user put on a digest cadence (hourly / 12h / daily / weekly) instead of getting pinged for each event.

One cron entry per cadence enqueues this worker with %{"cadence" => "hourly"} etc. The window is simply the cadence period (the hourly cron counts the last hour, daily the last day, …) — so there's no per-user last-sent state to track. For each user who routes a type to a channel on this cadence, it counts that type's events in the window from the activity log and, if any, delivers a single summary ("You have 1,432 new likes in the last hour.") via the channel.

Only activity-driven types aggregate — standalone notifications are always immediate. Immediate cadences never reach here (they enqueue DeliveryWorker at creation time).