fix(telegram): restore DM thread delivery after forum-only gate
Commit 9154971 changed resolveTelegramForumThreadId to return
undefined when is_forum is false. This broke DM thread delivery
because Telegram Bot API never sets is_forum=true for private chats.
Introduce effectiveThreadId that uses raw messageThreadId for DMs
while preserving forum-resolved value for groups.
This commit is contained in:
parent
5cad6d3f9d
commit
4ae5687b61
@ -161,6 +161,9 @@ export const buildTelegramMessageContext = async ({
|
|||||||
isForum,
|
isForum,
|
||||||
messageThreadId,
|
messageThreadId,
|
||||||
});
|
});
|
||||||
|
// Effective thread ID for outbound delivery: groups use forum-resolved; DMs use raw messageThreadId
|
||||||
|
// (private chats never set is_forum=true per Telegram Bot API, so resolvedThreadId is always undefined for DMs)
|
||||||
|
const effectiveThreadId = isGroup ? resolvedThreadId : messageThreadId;
|
||||||
const { groupConfig, topicConfig } = resolveTelegramGroupConfig(chatId, resolvedThreadId);
|
const { groupConfig, topicConfig } = resolveTelegramGroupConfig(chatId, resolvedThreadId);
|
||||||
const peerId = isGroup ? buildTelegramGroupPeerId(chatId, resolvedThreadId) : String(chatId);
|
const peerId = isGroup ? buildTelegramGroupPeerId(chatId, resolvedThreadId) : String(chatId);
|
||||||
const route = resolveAgentRoute({
|
const route = resolveAgentRoute({
|
||||||
@ -203,7 +206,8 @@ export const buildTelegramMessageContext = async ({
|
|||||||
const sendTyping = async () => {
|
const sendTyping = async () => {
|
||||||
await withTelegramApiErrorLogging({
|
await withTelegramApiErrorLogging({
|
||||||
operation: "sendChatAction",
|
operation: "sendChatAction",
|
||||||
fn: () => bot.api.sendChatAction(chatId, "typing", buildTypingThreadParams(resolvedThreadId)),
|
fn: () =>
|
||||||
|
bot.api.sendChatAction(chatId, "typing", buildTypingThreadParams(effectiveThreadId)),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -212,7 +216,11 @@ export const buildTelegramMessageContext = async ({
|
|||||||
await withTelegramApiErrorLogging({
|
await withTelegramApiErrorLogging({
|
||||||
operation: "sendChatAction",
|
operation: "sendChatAction",
|
||||||
fn: () =>
|
fn: () =>
|
||||||
bot.api.sendChatAction(chatId, "record_voice", buildTypingThreadParams(resolvedThreadId)),
|
bot.api.sendChatAction(
|
||||||
|
chatId,
|
||||||
|
"record_voice",
|
||||||
|
buildTypingThreadParams(effectiveThreadId),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logVerbose(`telegram record_voice cue failed for chat ${chatId}: ${String(err)}`);
|
logVerbose(`telegram record_voice cue failed for chat ${chatId}: ${String(err)}`);
|
||||||
@ -658,7 +666,7 @@ export const buildTelegramMessageContext = async ({
|
|||||||
msg,
|
msg,
|
||||||
chatId,
|
chatId,
|
||||||
isGroup,
|
isGroup,
|
||||||
resolvedThreadId,
|
resolvedThreadId: effectiveThreadId,
|
||||||
isForum,
|
isForum,
|
||||||
historyKey,
|
historyKey,
|
||||||
historyLimit,
|
historyLimit,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user