2.1 KiB
Discord Notifications
The notify capability provides reusable, queued Discord webhook delivery. Configure Queue, the webhook URL as an encrypted/write-only secret and allowed events (comma-separated names or *). Watchlist, Media Handoff and AI Subtitles independently select this provider in their own settings. Enablement alone sends nothing.
webhook_url(value) validates an official HTTPS Discord webhook path with numeric webhook ID and token. Accepted hosts are discord.com, discordapp.com, canary.discord.com and ptb.discord.com; credentials, nonstandard ports, query strings, fragments and unrelated hosts are rejected. The saved URL remains in encrypted plugin settings rather than queue payloads, templates or history.
Notifications.send(event, message) bounds event to 100 and message to 1800 characters, checks the configured event filter, and returns a job ID (or None when filtered). process(payload, progress) resolves the current secret, sends a bounded-time POST without following redirects, suppresses mentions through allowed_mentions, and reports completion. HTTP 429 becomes a retry-later failure; other non-success responses fail without exposing webhook credentials. Queue retries are explicit and delivery is at least once. The request follows Discord's webhook API.
Current producer events are watchlist.episodes, media.handoff, subtitles.completed and explicit test. Other trusted plugins can call send with their own event names.
GET /plugins/discord-notifications/ shows recent delivery job metadata and a test button. POST / requires content.write and CSRF, queues the test only if its event is allowed, audits the request and reports queued/filtered state. It does not dispatch from GET. service(), index() and test_notification() adapt these routes. The delivery worker consumes source-specific jobs, renews the claim and records queue logs/progress.
Automated tests mock Discord requests, validate secret storage/redaction boundaries, reject unofficial hosts, check mention suppression/event filtering, and inspect completed queue state. They never send real messages.