Feat/notification reliability hardening - #741
Merged
MaryammAli merged 2 commits intoAug 28, 2026
Merged
Conversation
…duplicate delivery Retries and scheduled jobs can send duplicate reminders or alerts. This adds an optional eventKey to Notification and CreateNotificationDto. When set, the service tracks recently seen keys within a configurable window (default 5 minutes) and suppresses duplicates. Provider retries carrying the same eventKey are safe — only the first attempt is persisted. Duplicates return a sentinel notification (id=__duplicate__) so callers can detect suppression without side-effects. The dedup window purges expired keys to prevent unbounded memory growth. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
… sanitisation Placeholder replacement now escapes HTML entities (&, <, >, ", ', /) and strips dangerous constructs (script, iframe, object, embed tags; javascript: URIs) before interpolation. This prevents XSS when user-supplied values (names, course titles, etc.) are inserted into email templates. Missing and unknown placeholders follow documented behaviour: known fields use sensible fallbacks, unknown fields render as [keyName] for predictable output. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@ustaxs Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardens the notification system across three reliability, security, and correctness dimensions. Addresses duplicate delivery from retries/scheduled jobs, XSS vulnerabilities in email templates, and race conditions in low-priority batch flushing.
Task 1: Notification Deduplication Keys (Reliability)
Added eventKey to Notification/DTO. Tracked in a TTL-based dedup window (configurable, default 5 min). Duplicates return a sentinel (id: 'duplicate'). Expired keys are purged to bound memory.
Closes BA-105 — Add notification deduplication keys #673
Task 2: Harden Email Template Interpolation (Security)
All interpolated values now pass through stripDangerousHtml() → escapeHtml(). Dangerous constructs (script, iframe, object, embed, javascript: URIs) are stripped. Unknown placeholders render as [keyName].
Closes BA-107 — Harden email template interpolation #675
Task 3: Concurrency-Safe Notification Batching (Bug Fix)
Added flushing boolean lock with try/finally. Batch is snapshot-and-swapped atomically before async provider calls. Concurrent flushes return empty results. Fixed pre-existing enabledProviders undefined variable bug.
Closes BA-108 — Make notification batching concurrency-safe #676