fix(telegram): include DM topic thread id in replies (#18586)

This commit is contained in:
Seb Slight
2026-02-16 17:02:59 -05:00
committed by GitHub
parent 1567d6cbb4
commit 0cff8bc4e6
4 changed files with 22 additions and 15 deletions

View File

@@ -114,7 +114,7 @@ export function resolveTelegramThreadSpec(params: {
* Build thread params for Telegram API calls (messages, media).
*
* IMPORTANT: Thread IDs behave differently based on chat type:
* - DMs (private chats): Never send thread_id (threads don't exist)
* - DMs (private chats): Include message_thread_id when present (DM topics)
* - Forum topics: Skip thread_id=1 (General topic), include others
* - Regular groups: Thread IDs are ignored by Telegram
*
@@ -130,9 +130,8 @@ export function buildTelegramThreadParams(thread?: TelegramThreadSpec | null) {
}
const normalized = Math.trunc(thread.id);
// Never send thread_id for DMs (threads don't exist in private chats)
if (thread.scope === "dm") {
return undefined;
return normalized > 0 ? { message_thread_id: normalized } : undefined;
}
// Telegram rejects message_thread_id=1 for General forum topic