diff --git a/overseerr-api.yml b/overseerr-api.yml index c4c1e97b..4619b565 100644 --- a/overseerr-api.yml +++ b/overseerr-api.yml @@ -1238,6 +1238,8 @@ components: type: string chatId: type: string + messageThreadId: + type: string sendSilently: type: boolean PushbulletSettings: @@ -1721,6 +1723,9 @@ components: telegramChatId: type: string nullable: true + telegramMessageThreadId: + type: string + nullable: true telegramSendSilently: type: boolean nullable: true diff --git a/server/lib/notifications/agents/telegram.ts b/server/lib/notifications/agents/telegram.ts index 7d706212..3c48b8cd 100644 --- a/server/lib/notifications/agents/telegram.ts +++ b/server/lib/notifications/agents/telegram.ts @@ -18,6 +18,7 @@ interface TelegramMessagePayload { text: string; parse_mode: string; chat_id: string; + message_thread_id: string; disable_notification: boolean; } @@ -26,6 +27,7 @@ interface TelegramPhotoPayload { caption: string; parse_mode: string; chat_id: string; + message_thread_id: string; disable_notification: boolean; } @@ -178,6 +180,7 @@ class TelegramAgent await axios.post(endpoint, { ...notificationPayload, chat_id: settings.options.chatId, + message_thread_id: settings.options.messageThreadId, disable_notification: !!settings.options.sendSilently, } as TelegramMessagePayload | TelegramPhotoPayload); } catch (e) { diff --git a/server/lib/settings.ts b/server/lib/settings.ts index 10213a04..ae8d9ea5 100644 --- a/server/lib/settings.ts +++ b/server/lib/settings.ts @@ -177,6 +177,7 @@ export interface NotificationAgentTelegram extends NotificationAgentConfig { botUsername?: string; botAPI: string; chatId: string; + messageThreadId: string; sendSilently: boolean; }; } @@ -357,6 +358,7 @@ class Settings { options: { botAPI: '', chatId: '', + messageThreadId: '', sendSilently: false, }, }, diff --git a/src/components/Settings/Notifications/NotificationsTelegram.tsx b/src/components/Settings/Notifications/NotificationsTelegram.tsx index 690731e6..34b09104 100644 --- a/src/components/Settings/Notifications/NotificationsTelegram.tsx +++ b/src/components/Settings/Notifications/NotificationsTelegram.tsx @@ -23,6 +23,9 @@ const messages = defineMessages({ chatId: 'Chat ID', chatIdTip: 'Start a chat with your bot, add @get_id_bot, and issue the /my_id command', + messageThreadId: 'Thread/Topic ID', + messageThreadIdTip: + "If your group-chat has topics enabled, you can specify a thread/topic's ID here", validationBotAPIRequired: 'You must provide a bot authorization token', validationChatIdRequired: 'You must provide a valid chat ID', telegramsettingssaved: 'Telegram notification settings saved successfully!', @@ -64,6 +67,7 @@ const NotificationsTelegram = () => { /^-?\d+$/, intl.formatMessage(messages.validationChatIdRequired) ), + messageThreadId: Yup.string().nullable(), }); if (!data && !error) { @@ -78,6 +82,7 @@ const NotificationsTelegram = () => { botUsername: data?.options.botUsername, botAPI: data?.options.botAPI, chatId: data?.options.chatId, + messageThreadId: data?.options.messageThreadId, sendSilently: data?.options.sendSilently, }} validationSchema={NotificationsTelegramSchema} @@ -89,6 +94,7 @@ const NotificationsTelegram = () => { options: { botAPI: values.botAPI, chatId: values.chatId, + messageThreadId: values.messageThreadId, sendSilently: values.sendSilently, botUsername: values.botUsername, }, @@ -137,6 +143,7 @@ const NotificationsTelegram = () => { options: { botAPI: values.botAPI, chatId: values.chatId, + messageThreadId: values.messageThreadId, sendSilently: values.sendSilently, botUsername: values.botUsername, }, @@ -269,6 +276,28 @@ const NotificationsTelegram = () => { )} +
+ +
+
+ +
+ {errors.messageThreadId && + touched.messageThreadId && + typeof errors.messageThreadId === 'string' && ( +
{errors.messageThreadId}
+ )} +
+