Repository navigation
feat(notifications): notify requesters of request status changes - #143
Conversation
Requests previously only notified the community server channels for submitted/approved/declined and the requester personally for fulfilled. This closes the gap and makes request posts addressable: - New request.approved / request.declined delivery types ride the operational dispatch path to the requesting profile: inbox, websocket toast, email, Discord DM, personal webhooks (gated by the existing notify_requests flag), and web push. Submitted stays broadcast-only (the requester performed the action themselves). Title/year/decline reason travel in reason_flags since no catalog item exists yet. - Request status notices are transactional: digest-mode recipients get an off-schedule early send (watermark-durable, last_digest_at left alone) instead of waiting for the digest hour. Per-episode recipients were already immediate via the dispatch nudge. - At-most-once per (profile, request, type) via a partial unique index (migration 20260612100000), mirroring the fulfilled dedupe. - Server-channel Discord request posts can @mention the requester via their OAuth-linked identity (notifications.server_channels. mention_requesters, default off). Resolved lazily in the sweep worker only when a Discord destination is about to receive the event; the ping uses content-level mention with pinned allowed_mentions, and the Discord identity never leaks into generic webhook payloads. Android/Apple clients render the new inbox types with their generic fallback until they add them. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Fable 5 <[email protected]>
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR extends the notification system to handle request lifecycle events (approved/declined) in addition to fulfillment. It introduces transactional notification support to bypass daily digest delays, adds Discord mention rendering for requesters, and updates all notification delivery formats (email, webhooks, web push) to render lifecycle events with appropriate metadata. ChangesRequest lifecycle notifications
Sequence Diagram(s)sequenceDiagram
participant RequestService as Request Service
participant Notifier as RequestLifecycleNotifier
participant SCWorker as ServerChannelWorker
participant Dispatch as DeliveryDispatcher
participant DiscordAPI as Discord API
RequestService->>Notifier: RequestApproved(ctx, request)
Notifier->>SCWorker: PostRequestEvent(approved event)
SCWorker->>DiscordAPI: POST webhook with mention + embed
Notifier->>Dispatch: dispatchRequestLifecycle(async)
Dispatch->>Dispatch: Build RequestFlags with title/year
Dispatch->>Dispatch: Marshal to reason_flags
Note over Dispatch: Send personal operational delivery to profile
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 373a338a66
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| err := r.pool.QueryRow(ctx, ` | ||
| SELECT EXISTS ( | ||
| SELECT 1 FROM notification_deliveries | ||
| WHERE profile_id = $1 AND (created_at, id) > ($2, $3) AND type = ANY($4) |
There was a problem hiding this comment.
Filter read request updates before bypassing digests
For digest-only recipients, this transactional pre-check ignores read_at, but processRecipient later filters read rows out for ChannelModeDailyDigest. If a user opens/marks a request.approved or request.declined inbox notification before the email/Discord worker runs while older unread episode rows are still behind the watermark, the read request row still triggers the off-schedule digest bypass and sends those unrelated rows immediately instead of at the digest hour. Add the same unread condition to the transactional existence checks (and the user-level variant above) or otherwise only bypass when an unread transactional row will actually be delivered.
Useful? React with 👍 / 👎.
| if flags.Reason != "" { | ||
| line += " — " + flags.Reason |
There was a problem hiding this comment.
Keep decline notes out of email subjects
When a declined request is the only item in a per-episode email, emailSubject returns requestLine(...), so this appends the full admin-supplied decline note to the email Subject. The decline textarea/API do not cap this value, so a long note can produce oversized headers and make the SMTP send fail or be rejected, causing the requester to miss the notification; keep the note in the body or truncate it before it can become the subject.
Useful? React with 👍 / 👎.
Requests previously only notified the community server channels for submitted/approved/declined and the requester personally for fulfilled. This closes the gap and makes request posts addressable: - New request.approved / request.declined delivery types ride the operational dispatch path to the requesting profile: inbox, websocket toast, email, Discord DM, personal webhooks (gated by the existing notify_requests flag), and web push. Submitted stays broadcast-only (the requester performed the action themselves). Title/year/decline reason travel in reason_flags since no catalog item exists yet. - Request status notices are transactional: digest-mode recipients get an off-schedule early send (watermark-durable, last_digest_at left alone) instead of waiting for the digest hour. Per-episode recipients were already immediate via the dispatch nudge. - At-most-once per (profile, request, type) via a partial unique index (migration 20260612100000), mirroring the fulfilled dedupe. - Server-channel Discord request posts can @mention the requester via their OAuth-linked identity (notifications.server_channels. mention_requesters, default off). Resolved lazily in the sweep worker only when a Discord destination is about to receive the event; the ping uses content-level mention with pinned allowed_mentions, and the Discord identity never leaks into generic webhook payloads. Android/Apple clients render the new inbox types with their generic fallback until they add them. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Fable 5 <[email protected]>
Problem
Request lifecycle events were community-facing only: submitted/approved/declined posted to admin server channels, and only fulfilled reached the requester personally. A user whose request was approved or declined never heard about it unless they checked the requests page. Server-channel request posts also had no way to tag the requesting user on Discord.
What this does
Personal approved/declined notifications. New
request.approved/request.declineddelivery types ride the existing operational dispatch path to the requesting profile — inbox, websocket toast, email, Discord DM, personal webhooks (gated by the existing per-webhooknotify_requestsflag), and web push. Submitted deliberately stays broadcast-only: the requester performed that action themselves. Since no catalog item exists pre-fulfillment, title/year/decline-reason travel inreason_flagsand every renderer reads them from there. The admin's decline reason is shown on all channels.Immediate delivery, even for digest users. Request status changes are transactional: a digest-mode recipient with one pending gets an off-schedule early send within seconds instead of waiting for the digest hour. The early send keeps full watermark durability and does not stamp
last_digest_at, so the daily schedule is unaffected. Applies to both Discord DMs and email via the shared account-channel engine; per-episode recipients were already immediate via the dispatch nudge.Requester @mentions in server channels. Opt-in server setting (
notifications.server_channels.mention_requesters, default off, in the Server Channels admin card): Discord request posts @mention the requester via their OAuth-linked Discord identity. Resolved lazily in the sweep worker only when a Discord destination is about to receive the event, pinged via content-level mention with pinnedallowed_mentions(embed mentions never ping; implicit parsing stays disabled so user-derived text can never ping roles/@everyone). Unlinked accounts fall back to the plain username; the Discord ID never leaks into generic webhook payloads.Dedupe migration.
20260612100000_request_lifecycle_notifications.sqladds a partial unique index per (profile, request, type), mirroring the fulfilled pattern, so API retries or multi-node races can't double-notify.Why this approach
Extending the delivery pipeline (rather than a Discord-specific side channel) lights up every notification channel at once and inherits the existing durability, dedupe, and preference gating. The transactional early-send is expressed at the engine level so both account channels share it and future transactional types just join the list.
Risks / follow-ups
silo-android/silo-applerender the two new inbox types with their generic fallback until they add them (type strings +reason_flagsdocumented inweb/src/api/types.ts).request.fulfilledkeeps its current digest-mode timing; making it transactional is a one-line change if desired.Request.DeclineReasonfield; the durable copy remains inmedia_request_events.Testing
allowed_mentionspinning, plain-username fallback).internal/...test sweep,go vet,gofmt, web ESLint/Prettier/tsc, and all 1059 web tests pass.AI use
Implemented with Claude Code (design discussed and decided with the maintainer; all code AI-written, human-reviewed).
🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Improvements