diff --git a/modules/notifications/lib/Module/Notifications/Service/NotificationService.php b/modules/notifications/lib/Module/Notifications/Service/NotificationService.php index be8abc2..216107f 100644 --- a/modules/notifications/lib/Module/Notifications/Service/NotificationService.php +++ b/modules/notifications/lib/Module/Notifications/Service/NotificationService.php @@ -9,13 +9,15 @@ class NotificationService { private const MESSAGE_META_KEY = '__message'; private const DEDUPE_WINDOW_MINUTES = 30; + + /** @var array Type → dedup window in minutes (true = default window). */ private const DEDUPE_TYPES = [ 'user.created' => true, 'user.deleted' => true, 'user.activated' => true, 'user.deactivated' => true, 'user.assignment_changed' => true, - 'scheduler.job_failed' => true, + 'scheduler.job_failed' => 1440, ]; public function __construct( @@ -233,6 +235,9 @@ class NotificationService return []; } + $windowMinutes = self::DEDUPE_TYPES[$type]; + $windowMinutes = is_int($windowMinutes) && $windowMinutes > 0 ? $windowMinutes : self::DEDUPE_WINDOW_MINUTES; + $tenantScope = $tenantId !== null && $tenantId > 0 ? $tenantId : 0; $raw = implode('|', [ 'recipient:' . $recipientUserId, @@ -243,7 +248,7 @@ class NotificationService return [ 'fingerprint' => hash('sha256', $raw), - 'bucket' => intdiv(time(), self::DEDUPE_WINDOW_MINUTES * 60), + 'bucket' => intdiv(time(), $windowMinutes * 60), ]; }