fix: preserve delivery thread fallback (#4911) (thanks @yevhen)

This commit is contained in:
Ayaan Zaidi
2026-01-31 09:23:40 +05:30
committed by Ayaan Zaidi
parent a642ca4ea8
commit 310eed825e
4 changed files with 17 additions and 2 deletions

View File

@@ -88,6 +88,20 @@ describe("delivery context helpers", () => {
accountId: undefined,
threadId: 42,
});
expect(
deliveryContextFromSession({
channel: "telegram",
lastTo: " -1001 ",
deliveryContext: { threadId: " 777 " },
origin: { threadId: 42 },
}),
).toEqual({
channel: "telegram",
to: "-1001",
accountId: undefined,
threadId: "777",
});
});
it("normalizes delivery fields and mirrors them on session entries", () => {

View File

@@ -98,7 +98,7 @@ export function deliveryContextFromSession(
lastChannel: entry.lastChannel,
lastTo: entry.lastTo,
lastAccountId: entry.lastAccountId,
lastThreadId: entry.lastThreadId ?? entry.origin?.threadId,
lastThreadId: entry.lastThreadId ?? entry.deliveryContext?.threadId ?? entry.origin?.threadId,
deliveryContext: entry.deliveryContext,
};
return normalizeSessionDeliveryFields(source).deliveryContext;