Skip to content

feat(notifications): add Discord thread ID support#3065

Open
Gilmoursa wants to merge 3 commits into
seerr-team:developfrom
Gilmoursa:feature-discord-thread-notifications
Open

feat(notifications): add Discord thread ID support#3065
Gilmoursa wants to merge 3 commits into
seerr-team:developfrom
Gilmoursa:feature-discord-thread-notifications

Conversation

@Gilmoursa
Copy link
Copy Markdown

@Gilmoursa Gilmoursa commented May 23, 2026

Description

Discord webhooks support posting to a specific thread by passing a thread_id query parameter in the webhook URL. While this is already possible by appending the parameter manually to the webhook URL, it's not obvious and easy to get wrong. This PR adds an explicit Thread ID field to the Discord notification agent settings to make thread routing a first-class, discoverable option.

How Has This Been Tested?

Ran the dev server on localhost and navigated to Settings → Notifications → Discord. Next, I verified that:

  • The Thread ID field renders below Notification Role ID with the correct tip text
  • Leaving the field blank and saving works without a validation error
  • Entering a non-numeric value (e.g. abc) shows the validation error and won't let you save
  • Entering a valid 18-digit ID saves successfully and persists on page refresh

I did not test against a live Discord webhook.

Screenshots / Logs (if applicable)

None

Checklist:

  • I have read and followed the contribution guidelines.
  • Disclosed any use of AI (see our policy)
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required)

AI Disclosure: I used Claude Code to help find the issue and develop the structure of the implementation.

Summary by CodeRabbit

  • New Features
    • Discord webhook notifications now support targeting specific threads. Users can configure a Thread ID to post notifications directly to designated Discord threads instead of the main channel.
    • Added Thread ID configuration field to Discord notification settings with built-in numeric validation.

Review Change Stack

Allow Discord webhook notifications to be sent to a specific thread by
optionally configuring a thread ID. When set, the thread_id query
parameter is appended to the webhook URL as documented in the Discord
API.

Closes seerr-team#2719
@Gilmoursa Gilmoursa requested a review from a team as a code owner May 23, 2026 14:43
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cc4d2d14-1b53-4130-99d7-d64ce57a64de

📥 Commits

Reviewing files that changed from the base of the PR and between edfd115 and 1c2a073.

📒 Files selected for processing (1)
  • src/components/Settings/Notifications/NotificationsDiscord.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/Settings/Notifications/NotificationsDiscord.tsx

📝 Walkthrough

Walkthrough

This PR adds Discord webhook thread support: settings gain an optional webhookThreadId, the server agent appends it as a thread_id query parameter when present, and the UI provides form fields, validation, i18n, and payload wiring to save and test thread IDs.

Changes

Discord Webhook Thread Support

Layer / File(s) Summary
Settings configuration type
server/lib/settings/index.ts
NotificationAgentDiscord.options gains optional webhookThreadId field.
Server-side Discord agent implementation
server/lib/notifications/agents/discord.ts
Agent constructs webhook URL from settings and conditionally sets the thread_id query parameter when webhookThreadId is configured; axios POST uses the computed URL.
Discord notifications UI form
src/components/Settings/Notifications/NotificationsDiscord.tsx, src/i18n/locale/en.json
Adds i18n keys and a Thread ID input with Yup validation (numeric Discord ID pattern), initializes Formik from saved settings, and includes webhookThreadId in save and test request payloads; renders label, tooltip, and validation errors.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • gauthier-th
  • M0NsTeRRR

Poem

I hop through code with thread in tow,
A webhook path where messages go,
From form to server, query set just right,
Discord threads now sparkle in the night,
Rabbit cheers — hop, send, delight! 🐰

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding Discord thread ID support to notifications. It is concise, specific, and directly reflects the primary feature being implemented across the changed files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server/lib/notifications/agents/discord.ts`:
- Around line 318-323: The current construction of webhookUrl by
string-concatenating `?thread_id=...` can produce malformed URLs when
`settings.options.webhookUrl` already has query params; update the logic that
sets `webhookUrl` to create a new URL object from `settings.options.webhookUrl`,
call `url.searchParams.set('thread_id', settings.options.webhookThreadId)` when
`settings.options.webhookThreadId` is present, and then use `url.toString()` for
the value passed to `axios.post`; replace the existing string-concat branch that
assigns `webhookUrl` and ensure any subsequent use (the `axios.post(webhookUrl,
...)` call) uses the safe URL string.

In `@src/components/Settings/Notifications/NotificationsDiscord.tsx`:
- Around line 75-80: The Yup schema for webhookThreadId in
NotificationsDiscord.tsx currently uses .nullable() but treats empty string ""
as invalid; update the validation for webhookThreadId to accept empty strings by
transforming them to null before applying the regex or marking the field not
required. For example, on the webhookThreadId field, add .transform(value =>
(value === "" ? null : value)) (or .notRequired()) prior to
.matches(/^\d{17,19}$/, ...) so empty input is allowed while still validating
numeric IDs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 426d3320-acf6-4e63-ae09-a521f3522048

📥 Commits

Reviewing files that changed from the base of the PR and between 32169d9 and 74201ef.

📒 Files selected for processing (4)
  • server/lib/notifications/agents/discord.ts
  • server/lib/settings/index.ts
  • src/components/Settings/Notifications/NotificationsDiscord.tsx
  • src/i18n/locale/en.json

Comment thread server/lib/notifications/agents/discord.ts Outdated
Comment thread src/components/Settings/Notifications/NotificationsDiscord.tsx Outdated
…lidation

Use the URL API instead of string concatenation to append thread_id as a
query parameter, preventing malformed URLs when the webhook URL already
contains query params.

Also transform empty string to null before Yup regex validation so leaving
the Thread ID field blank does not trigger a validation error.
@0xSysR3ll
Copy link
Copy Markdown
Contributor

Same as a previous PR; this does not address the real issue. Please see #3013 (comment)

@fallenbagel fallenbagel added blocked This issue can't be solved for now pending author's response labels May 24, 2026
@gauthier-th
Copy link
Copy Markdown
Member

Same as a previous PR; this does not address the real issue. Please see #3013 (comment)

Yes, the linked issue is wrong. But the feature itself is not wrong -- we may want to add an option on the UI to make it easier to specify a thread ID (for all Discord notifications).

@Gilmoursa
Copy link
Copy Markdown
Author

Thanks for the context. To clarify the scope: the Thread ID field is added to the Discord notification agent settings globally, not to a specific notification type, so it applies to all Discord notifications sent through that agent. Happy to update the linked issue if you can point me to a better one.

@0xSysR3ll
Copy link
Copy Markdown
Contributor

0xSysR3ll commented May 27, 2026

Thanks for the context. To clarify the scope: the Thread ID field is added to the Discord notification agent settings globally, not to a specific notification type, so it applies to all Discord notifications sent through that agent. Happy to update the linked issue if you can point me to a better one.

As it stands, yes. It doesn't address the originally requested feature. That said, as @gauthier-th mentioned, it could still be a valuable enhancement to improve the UX in the future.

So IMO, it would be better to simply remove the linked issue and slightly adjust the description to better reflect the current scope (sending notifications to a thread is already possible, it's just not obvious).

…idation

Yup's .matches() can reject empty strings even when .nullable() is set,
because the regex test runs before the null coercion is fully applied.
Adding excludeEmptyString: true ensures the optional thread ID field
passes validation when left blank.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked This issue can't be solved for now pending author's response

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants