PROD : OUT-4000 | Filter out email notifications according to iu notification preference - #1396
Conversation
…n preference Complete OUT-3929 IU email gating now that Copilot exposes GET /v1/internal-users/:id/notification-settings. Hybrid gating, split by send path: - Single emails: attach the resolved notificationSettingId on the body so the platform gates the send (re-enabled in NotificationService). - Grouped summaries: read the recipient IU's prefs and drop events for categories whose email is disabled before composing the summary (filterEventsForIuPreferences), fail-open on read error. - add CopilotAPI.getInternalUserNotificationSettings (not cached; live pref) - add InternalUserNotificationSettingsSchema - add iuEmailPreference helpers (disabledEmailSettingIds, isIuEmailGloballyOff) - tests for the helpers and the flush filter; flip obsolete ungated guard Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Only treat email as globally enabled when emailSettings is explicitly "active" (case-insensitive, trimmed). Any other value — a different disabled string, unexpected casing, or a missing field — is treated as not activated, so a global opt-out is never bypassed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…isableEmail emailSettings "not_active" does NOT mean the IU receives no email — a test IU with emailSettings=not_active still expects (and should get) comment emails. Gating on it suppressed every grouped IU email for that IU. The reliable signal is the per-category disableEmail flag, so gate on that alone. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…-preference OUT-4000 | Filter out email notifications according to iu notification preference
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Deployment failed with the following error: Learn More: https://vercel.link/multiple-function-regions |
Greptile SummaryThis PR enables Internal User notification-setting IDs and filters buffered grouped-email events using live IU preferences.
Confidence Score: 3/5This PR should not merge until preference-read failures stop delivering emails that recipients explicitly disabled. The new catch path converts any exhausted Copilot or response-validation failure into an ungated send, after which the affected buffer rows are marked sent and deleted. src/jobs/notifications/flush-grouped-email.ts Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[NotificationService resolves category setting ID] --> B[Buffer grouped email event]
B --> C[Grouped-email flush]
C --> D[Read IU notification preferences]
D -->|Success| E[Remove disabled categories]
D -->|Failure| F[Return all events unfiltered]
E --> G{Events remaining?}
F --> G
G -->|One| H[Replay individual email]
G -->|Multiple| I[Send grouped summary]
G -->|None| J[Send nothing]
H --> K[Mark sent and delete rows]
I --> K
Reviews (1): Last reviewed commit: "Merge branch 'production' into main" | Re-trigger Greptile |
| } catch (e) { | ||
| logger.error('flush-grouped-email: failed to read IU prefs; sending ungated', { | ||
| recipientIuId, | ||
| error: serializeError(e), | ||
| }) | ||
| return events | ||
| } |
There was a problem hiding this comment.
Preference failures bypass email opt-outs
When the Copilot preference request fails for an IU with disabled email categories, this catch returns every event unfiltered, causing opted-out emails to be sent before their buffer rows are marked sent and deleted.
Knowledge Base Used: Notifications flow: from task/comment event to delivered notification
There was a problem hiding this comment.
will create another pr for this.
No description provided.