refactor: share outbound base session setup

This commit is contained in:
Peter Steinberger 2026-03-13 22:01:52 +00:00
parent 2ebc7e3ded
commit a4a7958678
1 changed files with 18 additions and 6 deletions

View File

@ -532,6 +532,21 @@ function resolveMatrixSession(
};
}
function buildSimpleBaseSession(params: {
route: ResolveOutboundSessionRouteParams;
channel: string;
peer: RoutePeer;
}) {
const baseSessionKey = buildBaseSessionKey({
cfg: params.route.cfg,
agentId: params.route.agentId,
channel: params.channel,
accountId: params.route.accountId,
peer: params.peer,
});
return { baseSessionKey, peer: params.peer };
}
function resolveMSTeamsSession(
params: ResolveOutboundSessionRouteParams,
): OutboundSessionRoute | null {
@ -596,13 +611,10 @@ function resolveMattermostSession(
if (!rawId) {
return null;
}
const peer: RoutePeer = { kind: isUser ? "direct" : "channel", id: rawId };
const baseSessionKey = buildBaseSessionKey({
cfg: params.cfg,
agentId: params.agentId,
const { baseSessionKey, peer } = buildSimpleBaseSession({
route: params,
channel: "mattermost",
accountId: params.accountId,
peer,
peer: { kind: isUser ? "direct" : "channel", id: rawId },
});
const threadId = normalizeThreadId(params.replyToId ?? params.threadId);
const threadKeys = resolveThreadSessionKeys({