mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-14 02:31:24 +00:00
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { isSingleUseReplyToMode } from "openclaw/plugin-sdk/reply-reference";
|
|
import { parseSlackTarget } from "./targets.js";
|
|
|
|
export function resolveSlackAutoThreadId(params: {
|
|
to: string;
|
|
toolContext?: {
|
|
currentChannelId?: string;
|
|
currentThreadTs?: string;
|
|
replyToMode?: "off" | "first" | "all" | "batched";
|
|
hasRepliedRef?: { value: boolean };
|
|
};
|
|
}): string | undefined {
|
|
const context = params.toolContext;
|
|
if (!context?.currentThreadTs || !context.currentChannelId) {
|
|
return undefined;
|
|
}
|
|
if (context.replyToMode !== "all" && !isSingleUseReplyToMode(context.replyToMode ?? "off")) {
|
|
return undefined;
|
|
}
|
|
const parsedTarget = parseSlackTarget(params.to, { defaultKind: "channel" });
|
|
if (!parsedTarget || parsedTarget.kind !== "channel") {
|
|
return undefined;
|
|
}
|
|
if (parsedTarget.id.toLowerCase() !== context.currentChannelId.toLowerCase()) {
|
|
return undefined;
|
|
}
|
|
if (isSingleUseReplyToMode(context.replyToMode ?? "off") && context.hasRepliedRef?.value) {
|
|
return undefined;
|
|
}
|
|
return context.currentThreadTs;
|
|
}
|