mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-19 14:00:51 +00:00
Move all Slack channel implementation files from src/slack/ to extensions/slack/src/ and replace originals with shim re-exports. This follows the extension migration pattern for channel plugins. - Copy all .ts files to extensions/slack/src/ (preserving directory structure: monitor/, http/, monitor/events/, monitor/message-handler/) - Transform import paths: external src/ imports use relative paths back to src/, internal slack imports stay relative within extension - Replace all src/slack/ files with shim re-exports pointing to the extension copies - Update tsconfig.plugin-sdk.dts.json rootDir from "src" to "." so the DTS build can follow shim chains into extensions/ - Update write-plugin-sdk-entry-dts.ts re-export path accordingly - Preserve extensions/slack/index.ts, package.json, openclaw.plugin.json, src/channel.ts, src/runtime.ts, src/channel.test.ts (untouched)
35 lines
1.5 KiB
TypeScript
35 lines
1.5 KiB
TypeScript
import type {
|
|
ChannelThreadingContext,
|
|
ChannelThreadingToolContext,
|
|
} from "../../../src/channels/plugins/types.js";
|
|
import type { OpenClawConfig } from "../../../src/config/config.js";
|
|
import { resolveSlackAccount, resolveSlackReplyToMode } from "./accounts.js";
|
|
|
|
export function buildSlackThreadingToolContext(params: {
|
|
cfg: OpenClawConfig;
|
|
accountId?: string | null;
|
|
context: ChannelThreadingContext;
|
|
hasRepliedRef?: { value: boolean };
|
|
}): ChannelThreadingToolContext {
|
|
const account = resolveSlackAccount({
|
|
cfg: params.cfg,
|
|
accountId: params.accountId,
|
|
});
|
|
const configuredReplyToMode = resolveSlackReplyToMode(account, params.context.ChatType);
|
|
const hasExplicitThreadTarget = params.context.MessageThreadId != null;
|
|
const effectiveReplyToMode = hasExplicitThreadTarget ? "all" : configuredReplyToMode;
|
|
const threadId = params.context.MessageThreadId ?? params.context.ReplyToId;
|
|
// For channel messages, To is "channel:C…" — extract the bare ID.
|
|
// For DMs, To is "user:U…" which can't be used for reactions; fall back
|
|
// to NativeChannelId (the raw Slack channel id, e.g. "D…").
|
|
const currentChannelId = params.context.To?.startsWith("channel:")
|
|
? params.context.To.slice("channel:".length)
|
|
: params.context.NativeChannelId?.trim() || undefined;
|
|
return {
|
|
currentChannelId,
|
|
currentThreadTs: threadId != null ? String(threadId) : undefined,
|
|
replyToMode: effectiveReplyToMode,
|
|
hasRepliedRef: params.hasRepliedRef,
|
|
};
|
|
}
|