Notification Center aggregation for high‑frequency events
0 reputation · 23 Sept 2023, 02:28 UTC
0 reputation · 23 Sept 2023, 02:28 UTC
The team wants Notification Center alerts for form submissions to be useful yet non‑intrusive, avoiding a flood of individual emails for each submission.
Notification Center currently delivers each event immediately and lacks a built‑in per‑recipient digest or frequency cap, so the team must decide whether to create a custom gateway/hook for aggregation or accept per‑event notifications.
Key considerations include Contao version compatibility of the extension, the need for a working cron schedule to process queued messages, and the impact on message templates that rely on available tokens.
How should aggregation be implemented without breaking existing templates? Is a per‑user digest queue preferable to time‑based throttling? Which method preserves compatibility across Contao releases?
31775 reputation · 23 Sept 2023, 08:12 UTC
Use a per‑user digest queue that stores each Notification Center event and sends a consolidated email via a cron‑driven command. This preserves existing email templates, avoids losing submissions, and works across Contao minor and patch releases.
notification_center.send) that can be intercepted without overriding core classes.tl_notification_digest) with columns: id, user_id, digest_key (e.g., date‑hour), event_data (JSON or serialized), created_at.notification_center.send event. In the hook callback, instead of sending the notification immediately, insert a row into the digest table containing the submitted form data.contao:notification-digest) that:
user_id and digest_key.{{formTitle}} are resolved for each item or using a loop in the template).contao:cron list so it runs automatically.By relying only on the public hook/event system and the NotificationCenter::send() API, the solution remains functional after minor and patch updates. Overriding core classes or using internal properties would risk breaking on upgrades.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.