Gateway: coerce chat deliverable route boolean

This commit is contained in:
Vincent Koc
2026-03-06 01:05:03 -05:00
parent 9dab154519
commit a939a15607

View File

@@ -906,13 +906,14 @@ export const chatHandlers: GatewayRequestHandlers = {
(isChannelScopedSession || hasLegacyChannelPeerShape)) ||
(isConfiguredMainSessionScope && client?.connect !== undefined && !isFromWebchatClient)),
);
const hasDeliverableRoute =
const hasDeliverableRoute = Boolean(
shouldDeliverExternally &&
canInheritDeliverableRoute &&
routeChannelCandidate &&
routeChannelCandidate !== INTERNAL_MESSAGE_CHANNEL &&
typeof routeToCandidate === "string" &&
routeToCandidate.trim().length > 0;
routeToCandidate.trim().length > 0,
);
const originatingChannel = hasDeliverableRoute
? routeChannelCandidate
: INTERNAL_MESSAGE_CHANNEL;