mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-25 17:02:46 +00:00
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import {
|
|
buildChannelOutboundSessionRoute,
|
|
stripChannelTargetPrefix,
|
|
stripTargetKindPrefix,
|
|
type ChannelOutboundSessionRouteParams,
|
|
} from "openclaw/plugin-sdk/core";
|
|
|
|
export function resolveMSTeamsOutboundSessionRoute(params: ChannelOutboundSessionRouteParams) {
|
|
let trimmed = stripChannelTargetPrefix(params.target, "msteams", "teams");
|
|
if (!trimmed) {
|
|
return null;
|
|
}
|
|
|
|
const lower = trimmed.toLowerCase();
|
|
const isUser = lower.startsWith("user:");
|
|
const rawId = stripTargetKindPrefix(trimmed);
|
|
if (!rawId) {
|
|
return null;
|
|
}
|
|
const conversationId = rawId.split(";")[0] ?? rawId;
|
|
const isChannel = !isUser && /@thread\.tacv2/i.test(conversationId);
|
|
return buildChannelOutboundSessionRoute({
|
|
cfg: params.cfg,
|
|
agentId: params.agentId,
|
|
channel: "msteams",
|
|
accountId: params.accountId,
|
|
peer: {
|
|
kind: isUser ? "direct" : isChannel ? "channel" : "group",
|
|
id: conversationId,
|
|
},
|
|
chatType: isUser ? "direct" : isChannel ? "channel" : "group",
|
|
from: isUser
|
|
? `msteams:${conversationId}`
|
|
: isChannel
|
|
? `msteams:channel:${conversationId}`
|
|
: `msteams:group:${conversationId}`,
|
|
to: isUser ? `user:${conversationId}` : `conversation:${conversationId}`,
|
|
});
|
|
}
|