mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-27 17:11:46 +00:00
fix: preserve telegram topic routing in announce and delivery context
This commit is contained in:
committed by
Peter Steinberger
parent
1b94e8ca14
commit
e643ba2f5e
@@ -123,6 +123,7 @@ describe("extractDeliveryInfo", () => {
|
||||
to: "group:98765",
|
||||
accountId: "main",
|
||||
});
|
||||
storeState.store[baseKey].lastThreadId = "55";
|
||||
|
||||
const result = extractDeliveryInfo(topicKey);
|
||||
|
||||
@@ -131,8 +132,33 @@ describe("extractDeliveryInfo", () => {
|
||||
channel: "telegram",
|
||||
to: "group:98765",
|
||||
accountId: "main",
|
||||
threadId: "55",
|
||||
},
|
||||
threadId: "55",
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to session metadata thread ids when deliveryContext.threadId is missing", () => {
|
||||
const sessionKey = "agent:main:telegram:group:98765";
|
||||
storeState.store[sessionKey] = {
|
||||
...buildEntry({
|
||||
channel: "telegram",
|
||||
to: "group:98765",
|
||||
accountId: "main",
|
||||
}),
|
||||
origin: { threadId: 77 },
|
||||
};
|
||||
|
||||
const result = extractDeliveryInfo(sessionKey);
|
||||
|
||||
expect(result).toEqual({
|
||||
deliveryContext: {
|
||||
channel: "telegram",
|
||||
to: "group:98765",
|
||||
accountId: "main",
|
||||
threadId: "77",
|
||||
},
|
||||
threadId: undefined,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,7 +15,9 @@ export function parseSessionThreadInfo(sessionKey: string | undefined): {
|
||||
}
|
||||
|
||||
export function extractDeliveryInfo(sessionKey: string | undefined): {
|
||||
deliveryContext: { channel?: string; to?: string; accountId?: string } | undefined;
|
||||
deliveryContext:
|
||||
| { channel?: string; to?: string; accountId?: string; threadId?: string }
|
||||
| undefined;
|
||||
threadId: string | undefined;
|
||||
} {
|
||||
const { baseSessionKey, threadId } = parseSessionThreadInfo(sessionKey);
|
||||
@@ -23,7 +25,9 @@ export function extractDeliveryInfo(sessionKey: string | undefined): {
|
||||
return { deliveryContext: undefined, threadId };
|
||||
}
|
||||
|
||||
let deliveryContext: { channel?: string; to?: string; accountId?: string } | undefined;
|
||||
let deliveryContext:
|
||||
| { channel?: string; to?: string; accountId?: string; threadId?: string }
|
||||
| undefined;
|
||||
try {
|
||||
const cfg = loadConfig();
|
||||
const storePath = resolveStorePath(cfg.session?.store);
|
||||
@@ -33,10 +37,13 @@ export function extractDeliveryInfo(sessionKey: string | undefined): {
|
||||
entry = store[baseSessionKey];
|
||||
}
|
||||
if (entry?.deliveryContext) {
|
||||
const resolvedThreadId =
|
||||
entry.deliveryContext.threadId ?? entry.lastThreadId ?? entry.origin?.threadId;
|
||||
deliveryContext = {
|
||||
channel: entry.deliveryContext.channel,
|
||||
to: entry.deliveryContext.to,
|
||||
accountId: entry.deliveryContext.accountId,
|
||||
threadId: resolvedThreadId != null ? String(resolvedThreadId) : undefined,
|
||||
};
|
||||
}
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user