mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 00:33:31 +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:
@@ -6,6 +6,14 @@ export function parseTelegramReplyToMessageId(replyToId?: string | null): number
|
||||
return Number.isFinite(parsed) ? parsed : undefined;
|
||||
}
|
||||
|
||||
function parseIntegerId(value: string): number | undefined {
|
||||
if (!/^-?\d+$/.test(value)) {
|
||||
return undefined;
|
||||
}
|
||||
const parsed = Number.parseInt(value, 10);
|
||||
return Number.isFinite(parsed) ? parsed : undefined;
|
||||
}
|
||||
|
||||
export function parseTelegramThreadId(threadId?: string | number | null): number | undefined {
|
||||
if (threadId == null) {
|
||||
return undefined;
|
||||
@@ -17,6 +25,8 @@ export function parseTelegramThreadId(threadId?: string | number | null): number
|
||||
if (!trimmed) {
|
||||
return undefined;
|
||||
}
|
||||
const parsed = Number.parseInt(trimmed, 10);
|
||||
return Number.isFinite(parsed) ? parsed : undefined;
|
||||
// DM topic session keys may scope thread ids as "<chatId>:<threadId>".
|
||||
const scopedMatch = /^-?\d+:(-?\d+)$/.exec(trimmed);
|
||||
const rawThreadId = scopedMatch ? scopedMatch[1] : trimmed;
|
||||
return parseIntegerId(rawThreadId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user