Fix telegram threadId in deliveryContext

This commit is contained in:
Yevhen Bobrov
2026-01-30 07:55:58 +02:00
committed by Ayaan Zaidi
parent e849df64dc
commit a642ca4ea8
3 changed files with 31 additions and 3 deletions

View File

@@ -90,10 +90,18 @@ export function normalizeSessionDeliveryFields(source?: DeliveryContextSessionSo
}
export function deliveryContextFromSession(
entry?: DeliveryContextSessionSource,
entry?: DeliveryContextSessionSource & { origin?: { threadId?: string | number } },
): DeliveryContext | undefined {
if (!entry) return undefined;
return normalizeSessionDeliveryFields(entry).deliveryContext;
const source: DeliveryContextSessionSource = {
channel: entry.channel,
lastChannel: entry.lastChannel,
lastTo: entry.lastTo,
lastAccountId: entry.lastAccountId,
lastThreadId: entry.lastThreadId ?? entry.origin?.threadId,
deliveryContext: entry.deliveryContext,
};
return normalizeSessionDeliveryFields(source).deliveryContext;
}
export function mergeDeliveryContext(