Skip to content

Feat/notification reliability hardening - #741

Merged
MaryammAli merged 2 commits into
BlockDash-Studios:mainfrom
ustaxs:feat/notification-reliability-hardening
Aug 28, 2026
Merged

Feat/notification reliability hardening#741
MaryammAli merged 2 commits into
BlockDash-Studios:mainfrom
ustaxs:feat/notification-reliability-hardening

Conversation

@ustaxs

@ustaxs ustaxs commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

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

ustaxs and others added 2 commits August 28, 2026 14:36
…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>
@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@MaryammAli MaryammAli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MaryammAli
MaryammAli merged commit 3207ca3 into BlockDash-Studios:main Aug 28, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants