Repository navigation
feat(notifications): in-app inbox, realtime, webhooks, web push + shared SMTP core #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
9befb5e
docs(notifications): import notification design docs, add web push + …
Quick104 60cd5a7
feat(notifications): in-app inbox, realtime, webhooks, web push + sha…
Quick104 16bdacb
feat(web): admin settings page for notification controls
Quick104 17a6745
feat(notifications): request-fulfilled notifications across all channels
Quick104 305e009
feat(web): show web push delivery health in notification settings
Quick104 8214c9b
fix(notifications): address PR #136 review findings
Quick104 9381d0e
feat(notifications): email notification channel
Quick104 6fd4c31
feat(notifications): gate user webhooks behind admin opt-in
Quick104 e95d650
feat(notifications): Discord bot DM channel with account linking
Quick104 c015521
feat(notifications): per-profile email channel with verified addresses
Quick104 5d7ef15
feat(notifications): branded HTML email templates
Quick104 81c9f18
fix(notifications): drain digest window fully and re-check kill switc…
Quick104 01b5479
fix(api): move account-level Discord routes out of RequireProfile
Quick104 65d4b3b
feat(notifications): admin server channels broadcasting new content a…
Quick104 2372a12
fix(web): type server channel event field tables explicitly
Quick104 64afa4f
feat(notifications): rich Discord embeds with posters, provider links…
Quick104 011c8c8
feat(web): redesign admin notifications settings around pipeline and …
Quick104 e1b5bab
fix(web): add padding and hierarchy to notification preferences popover
Quick104 f25d483
fix(notifications): address code review findings
Quick104 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Outbound Email (`internal/mail`) | ||
|
|
||
| **Status:** Implemented 2026-06-11 | ||
|
|
||
| Silo's shared outbound email facility. It is deliberately feature-agnostic: any | ||
| feature that sends mail (notification emails, account flows, invites) composes | ||
| a `mail.Message` and hands it to the shared `mail.Sender`, so SMTP | ||
| configuration, security policy, and diagnostics live in exactly one place. | ||
|
|
||
| ## Abstraction | ||
|
|
||
| ```go | ||
| type Sender interface { | ||
| Enabled(ctx context.Context) bool | ||
| Send(ctx context.Context, msg Message) error | ||
| } | ||
| ``` | ||
|
|
||
| `Message` carries recipients, subject, and text and/or HTML bodies (both set → | ||
| multipart/alternative). `Send` returns `mail.ErrNotConfigured` when email is | ||
| disabled or incomplete, so features treat email as an optional transport and | ||
| degrade gracefully. The SMTP implementation (`mail.NewSMTPSender`) is backed by | ||
| `github.com/wneessen/go-mail`. | ||
|
|
||
| ## Configuration | ||
|
|
||
| Live server settings (no restart required; read on every send — volume is | ||
| low): | ||
|
|
||
| | Key | Default | Notes | | ||
| |---|---|---| | ||
| | `email.enabled` | `false` | master switch | | ||
| | `email.smtp_host` | — | required | | ||
| | `email.smtp_port` | `587` | | | ||
| | `email.smtp_security` | `starttls` | `starttls` \| `tls` (implicit, port 465) \| `none` | | ||
| | `email.smtp_username` | — | empty = no auth | | ||
| | `email.smtp_password` | — | encrypted at rest (`SensitiveSettingKeys`) | | ||
| | `email.from_address` | — | required | | ||
| | `email.from_name` | `Silo` | | | ||
|
|
||
| Admin UI: Admin Settings → Connections → Email, including a synchronous test | ||
| send (`POST /api/v1/admin/email/test`). | ||
|
|
||
| ## Adding a consumer | ||
|
|
||
| Construct messages in the feature package and send through a `mail.Sender` | ||
| dependency. Do not read `email.*` settings from feature code, and check | ||
| `Enabled` (or branch on `ErrNotConfigured`) rather than treating a missing | ||
| SMTP configuration as an error. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # Web Push Spec | ||
|
|
||
| **Date:** 2026-06-11 | ||
| **Status:** Implemented | ||
| **Scope:** Browser push notifications (Push API + VAPID) as a third push platform alongside the deferred APNs/FCM channels. | ||
| **Depends On:** | ||
| - [`00-architecture-overview.md`](./00-architecture-overview.md) | ||
| - [`01-release-events-and-inbox.md`](./01-release-events-and-inbox.md) | ||
|
|
||
| ## Why Web Push ships before APNs/FCM | ||
|
|
||
| The architecture overview deferred mobile push because Apple and Google require pushes to official store builds to be signed by the publisher's credentials, forcing a Silo-operated relay. Web Push has neither problem: | ||
|
|
||
| - **No accounts, no relay.** The server self-provisions a VAPID keypair on first use. Any standards-compliant browser push service (Chrome, Firefox, Edge, Safari 16+) accepts VAPID-signed requests from any origin. | ||
| - **Content-safe by protocol.** Payloads are encrypted end-to-end (RFC 8291, `aes128gcm`) to keys held only by the subscribed browser. The vendor push service relays ciphertext. Unlike the APNs/FCM design, payloads can therefore carry full display content (titles, episode numbers, poster URLs) without violating the self-hosted privacy model — there is no opaque-wake/fetch dance. | ||
|
|
||
| The residual leak matches the relay threat model: the push service sees the user server's egress IP, delivery timing, and payload size. It never sees content or identity. | ||
|
|
||
| ## Data model | ||
|
|
||
| - `web_push_subscriptions` — profile-scoped browser registrations: `endpoint` (unique; a resubscription from the same browser under a different profile reassigns the row), `p256dh`, `auth`, `device_name`, failure bookkeeping. No FK to profiles (per-user SQLite stores); profile deletion purges in code. | ||
| - `web_push_delivery_attempts` — the durable dispatch outbox, mirroring `webhook_delivery_attempts`: `pending` rows enqueued in the fanout transaction, claimed post-commit with a lease, swept by the retry loop after a crash. | ||
|
|
||
| ## VAPID identity | ||
|
|
||
| Generated once and persisted in `server_settings`: | ||
|
|
||
| - `notifications.web_push.vapid_public_key` — served to clients via the capability endpoint. | ||
| - `notifications.web_push.vapid_private_key` — encrypted at rest (`SensitiveSettingKeys`). | ||
|
|
||
| The private key is persisted before the public key so a crash between writes regenerates the pair instead of stranding clients with an unusable public key. The pair must never be rotated casually: browsers bind subscriptions to it. | ||
|
|
||
| ## API surface (profile-scoped) | ||
|
|
||
| - `GET /api/v1/notifications/capability` — `web_push: { available, public_key }`. | ||
| - `POST /api/v1/notifications/web-push/subscriptions` — body is `PushSubscription.toJSON()` plus `device_name`. | ||
| - `GET /api/v1/notifications/web-push/subscriptions` — for the settings UI device list. | ||
| - `DELETE /api/v1/notifications/web-push/subscriptions/{id}` | ||
| - `POST /api/v1/notifications/web-push/unsubscribe` — by endpoint (browsers don't know row IDs). | ||
|
|
||
| Subscription endpoints are attacker-controllable URLs the server will POST to, so they pass the same HTTPS + private-destination guard as webhooks, both at registration and at connect time (guarded dialer). | ||
|
|
||
| ## Delivery semantics | ||
|
|
||
| - Fanout enqueues one `pending` attempt per enabled subscription of each recipient profile, in the same transaction as the delivery rows. No per-reason filters: profile preferences already gate delivery creation. | ||
| - Retry schedule is short (30s/2m/10m/30m, 5 attempts): vendor push services queue messages for offline devices themselves (TTL 12h), so server-side retries only ride out transient push-service errors. | ||
| - `404`/`410` from the push service is the protocol's unsubscribe signal: the subscription row is deleted, not retried. | ||
| - `notifications.web_push_enabled` is the kill switch (default on). | ||
|
|
||
| ## Client | ||
|
|
||
| - `web/public/sw.js` — displays notifications and routes clicks (episode deep link, or the inbox). | ||
| - `web/src/lib/webPush.ts` — permission + subscribe/unsubscribe flows. | ||
| - Settings → Notifications → "Browser Notifications" — this-browser toggle plus a revocable list of the profile's other subscribed devices. |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This detector is attached only after
libraryScanQueue.Start()has already launched workers earlier inmain, so any accepted scan resumed during startup can complete whileExecutor.availabilityis still nil and skipHandleIngestCompleted. In that startup window newly matched episodes are never recorded inepisode_availabilityand no release events are created, so interested profiles miss notifications for those arrivals; install the detector before starting the scan queue (or delay workers until after this block).Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 8214c9b.
libraryScanQueue.Start()(and itsStopdefer) moved below the notification-system block, so scan workers cannot resume an accepted scan beforeSetAvailabilityDetectorhas run.