Skip to content

Conversation

@pythcon
Copy link

@pythcon pythcon commented Jun 15, 2025

Description

This PR adds support for Telegram message thread IDs, allowing notifications to be sent to specific threads/topics within Telegram groups. This feature is particularly useful for organizing different types of notifications in group chats.

Key changes:

  • Added messageThreadId field to Telegram notification settings in both system and user settings
  • Updated the Telegram notification agent to include message thread ID in API requests
  • Added UI components for configuring message thread ID in user settings
  • Added validation for message thread ID input
  • Updated database schema to store message thread ID
  • Added proper type definitions and interfaces

The message thread ID is optional and can be configured at both the system level (for all notifications) and user level (for individual user notifications). When configured, notifications will be sent to the specified thread within the Telegram group chat.

Screenshot (if UI-related)

TelegramMessageThreadID

To-Dos

  • Successful build yarn build
  • Translation keys yarn i18n:extract
  • Database migration (if required)

@pythcon pythcon marked this pull request as ready for review June 15, 2025 21:50
@sct sct requested a review from Copilot June 18, 2025 01:03
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds support for specifying Telegram message thread IDs in notifications.

  • Introduces a new messageThreadId field across UI, API, and database schema
  • Updates the Telegram agent to include message_thread_id in API calls when provided
  • Adds validation, type definitions, and documentation updates for the new field

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/components/UserProfile/UserSettings/UserNotificationSettings/UserNotificationsTelegram.tsx Added UI field, validation, and form mapping for thread ID
src/components/Settings/Notifications/NotificationsTelegram.tsx Added system settings UI and schema update for thread ID
server/routes/user/usersettings.ts Extended user settings routes to read and write thread ID
server/lib/settings.ts Updated settings interface and default values for thread ID
server/lib/notifications/agents/telegram.ts Included thread ID in message payload when present
server/interfaces/api/userSettingsInterfaces.ts Exposed telegramMessageThreadId in API response
server/entity/UserSettings.ts Added database column for telegramMessageThreadId
docs/using-overseerr/notifications/webhooks.md Documented new template variable for thread ID
docs/using-overseerr/notifications/telegram.md Added documentation for obtaining thread ID
Comments suppressed due to low confidence (2)

server/routes/user/usersettings.ts:324

  • The 'telegramMessageThreadId' value from the request body is assigned without server-side validation or sanitization. It would be safer to validate that this value matches the expected numeric pattern before storing or using it.
          telegramMessageThreadId: req.body.telegramMessageThreadId,

server/lib/notifications/agents/telegram.ts:184

  • There are no tests covering the new inclusion of 'message_thread_id' in the Telegram payload. Consider adding unit tests to verify that the thread ID is correctly added when provided and omitted when absent.
          ...(settings.options.messageThreadId

),
telegramMessageThreadId: Yup.string()
.nullable()
.matches(/^\d*$/, intl.formatMessage(messages.validationTelegramChatId)),
Copy link

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

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

The validation message for 'telegramMessageThreadId' reuses the chat ID error key and message, which may confuse users. Consider adding a dedicated validation message key (e.g., validationTelegramThreadId) with an appropriate message.

Suggested change
.matches(/^\d*$/, intl.formatMessage(messages.validationTelegramChatId)),
.matches(/^\d*$/, intl.formatMessage(messages.validationTelegramThreadId)),

Copilot uses AI. Check for mistakes.
),
messageThreadId: Yup.string()
.nullable()
.matches(/^\d*$/, intl.formatMessage(messages.validationChatIdRequired)),
Copy link

Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

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

This validation for 'messageThreadId' reuses the chat ID error message. You should define a specific validation message for the thread ID (e.g., validationMessageThreadIdRequired) to provide clear feedback.

Suggested change
.matches(/^\d*$/, intl.formatMessage(messages.validationChatIdRequired)),
.matches(/^\d*$/, intl.formatMessage(messages.validationMessageThreadIdRequired)),

Copilot uses AI. Check for mistakes.
@gragragrab
Copy link

Duplicate #4134

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants