Skip to content

fix(notifications): enforce category preferences on every generation path (closes #1605) - #1799

Open
rudrasatani13 wants to merge 2 commits into
Arena1X:mainfrom
rudrasatani13:fix/1605-category-preference-enforcement
Open

fix(notifications): enforce category preferences on every generation path (closes #1605)#1799
rudrasatani13 wants to merge 2 commits into
Arena1X:mainfrom
rudrasatani13:fix/1605-category-preference-enforcement

Conversation

@rudrasatani13

Copy link
Copy Markdown

Closes #1605.

What was wrong

The preference check existed - shouldSendNotification reads the legacy per-type flags and the per-category row - but it was only wired into three of the generation paths: handleEventCreated, handleUserJoinedEvent and handlePredictionSubmitted. The other seven queued unconditionally:

  • handleMatchAdded, handleMatchResultSubmitted, handleWinnersVerified, handleEventCancelled
  • notifyDisputeSlaApproaching, notifyDisputeSlaBreached, notifyOracleDivergence

So a user who turned a category off still received those notifications.

What changed

  • isAllowedByPreferences(prefs, categoryPreference, type) - the decision itself, extracted so the single-recipient path and the batched path cannot drift apart. Legacy per-type flags still reject when explicitly false, and a missing category row still counts as opted in (the safe fallback).
  • filterAllowedRecipients(addresses, type) - a batched filter: one user query plus one category-preference query for the whole recipient list, rather than two queries per recipient. An address with no user record is kept, which matches what the single-recipient path already did.
  • The seven paths above now filter their recipients through it before queueing.

Tests

Three new cases in notification-generator.service.spec.ts: a disabled category produces no notification, an enabled category does, and a missing category row is treated as opted in. The category-preference repository mock gained the find the batched filter uses.

Verification:

  • npx jest src/notifications -> 6 suites, 133 tests passing (130 before, plus the three new ones).
  • npx tsc --noEmit -> 66 pre-existing errors repo-wide, unchanged from before this branch, and none in the two files touched here.

Assignment and reward are not confirmed on my side, so please treat this as a voluntary contribution. I applied for the issue on GrantFox (#1605).

@vercel

vercel Bot commented Sep 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
insight-arena-4rll Ready Ready Preview Sep 13, 2026 2:46pm UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Backend] — Notification Category Preference Enforcement

1 participant