mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 22:46:39 +00:00
fix(telegram): scope DM topic thread keys by chat id (#31064)
* fix(telegram): scope DM topic thread keys by chat id * test(telegram): update dm topic session-key expectation * fix(telegram): parse scoped dm thread ids in outbound recovery * chore(telegram): format accounts config merge block * test(nodes): simplify mocked exports for ts tuple spreads
This commit is contained in:
@@ -20,6 +20,7 @@ import { normalizeAllowListLower } from "../../slack/monitor/allow-list.js";
|
||||
import { parseSlackTarget } from "../../slack/targets.js";
|
||||
import { buildTelegramGroupPeerId } from "../../telegram/bot/helpers.js";
|
||||
import { resolveTelegramTargetChatType } from "../../telegram/inline-buttons.js";
|
||||
import { parseTelegramThreadId } from "../../telegram/outbound-params.js";
|
||||
import { parseTelegramTarget } from "../../telegram/targets.js";
|
||||
import { isWhatsAppGroupJid, normalizeWhatsAppTarget } from "../../whatsapp/normalize.js";
|
||||
import type { ResolvedMessagingTarget } from "./target-resolver.js";
|
||||
@@ -283,8 +284,7 @@ function resolveTelegramSession(
|
||||
}
|
||||
const parsedThreadId = parsed.messageThreadId;
|
||||
const fallbackThreadId = normalizeThreadId(params.threadId);
|
||||
const resolvedThreadId =
|
||||
parsedThreadId ?? (fallbackThreadId ? Number.parseInt(fallbackThreadId, 10) : undefined);
|
||||
const resolvedThreadId = parsedThreadId ?? parseTelegramThreadId(fallbackThreadId);
|
||||
// Telegram topics are encoded in the peer id (chatId:topic:<id>).
|
||||
const chatType = resolveTelegramTargetChatType(params.target);
|
||||
// If the target is a username and we lack a resolvedTarget, default to DM to avoid group keys.
|
||||
|
||||
@@ -891,6 +891,7 @@ describe("resolveOutboundSessionRoute", () => {
|
||||
channel: string;
|
||||
target: string;
|
||||
replyToId?: string;
|
||||
threadId?: string;
|
||||
expected: {
|
||||
sessionKey: string;
|
||||
from?: string;
|
||||
@@ -934,6 +935,20 @@ describe("resolveOutboundSessionRoute", () => {
|
||||
chatType: "direct",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Telegram DM scoped threadId fallback",
|
||||
cfg: perChannelPeerCfg,
|
||||
channel: "telegram",
|
||||
target: "12345",
|
||||
threadId: "12345:99",
|
||||
expected: {
|
||||
sessionKey: "agent:main:telegram:direct:12345",
|
||||
from: "telegram:12345",
|
||||
to: "telegram:12345",
|
||||
threadId: 99,
|
||||
chatType: "direct",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "identity-links per-peer",
|
||||
cfg: identityLinksCfg,
|
||||
@@ -1018,6 +1033,7 @@ describe("resolveOutboundSessionRoute", () => {
|
||||
agentId: "main",
|
||||
target: testCase.target,
|
||||
replyToId: testCase.replyToId,
|
||||
threadId: testCase.threadId,
|
||||
});
|
||||
expect(route?.sessionKey, testCase.name).toBe(testCase.expected.sessionKey);
|
||||
if (testCase.expected.from !== undefined) {
|
||||
|
||||
Reference in New Issue
Block a user