From 260a514467d99b168a9439a6ad993327d5a8add9 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 16 Feb 2026 01:06:18 +0000 Subject: [PATCH] refactor(slack): share channel config entry type --- src/slack/monitor/channel-config.ts | 25 +++++++++++++------------ src/slack/monitor/context.ts | 14 ++------------ 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/slack/monitor/channel-config.ts b/src/slack/monitor/channel-config.ts index 6d35cb1ae69..0d34209e422 100644 --- a/src/slack/monitor/channel-config.ts +++ b/src/slack/monitor/channel-config.ts @@ -19,6 +19,18 @@ export type SlackChannelConfigResolved = { matchSource?: ChannelMatchSource; }; +export type SlackChannelConfigEntry = { + enabled?: boolean; + allow?: boolean; + requireMention?: boolean; + allowBots?: boolean; + users?: Array; + skills?: string[]; + systemPrompt?: string; +}; + +export type SlackChannelConfigEntries = Record; + function firstDefined(...values: Array) { for (const value of values) { if (typeof value !== "undefined") { @@ -74,18 +86,7 @@ export function resolveSlackChannelLabel(params: { channelId?: string; channelNa export function resolveSlackChannelConfig(params: { channelId: string; channelName?: string; - channels?: Record< - string, - { - enabled?: boolean; - allow?: boolean; - requireMention?: boolean; - allowBots?: boolean; - users?: Array; - skills?: string[]; - systemPrompt?: string; - } - >; + channels?: SlackChannelConfigEntries; defaultRequireMention?: boolean; }): SlackChannelConfigResolved | null { const { channelId, channelName, channels, defaultRequireMention } = params; diff --git a/src/slack/monitor/context.ts b/src/slack/monitor/context.ts index 57f5fbc2550..d95297e1e25 100644 --- a/src/slack/monitor/context.ts +++ b/src/slack/monitor/context.ts @@ -4,6 +4,7 @@ import type { OpenClawConfig, SlackReactionNotificationMode } from "../../config import type { DmPolicy, GroupPolicy } from "../../config/types.js"; import type { RuntimeEnv } from "../../runtime.js"; import type { SlackMessageEvent } from "../types.js"; +import type { SlackChannelConfigEntries } from "./channel-config.js"; import { formatAllowlistMatchMeta } from "../../channels/allowlist-match.js"; import { resolveSessionKey, type SessionScope } from "../../config/sessions.js"; import { logVerbose } from "../../globals.js"; @@ -70,18 +71,7 @@ export type SlackMonitorContext = { groupDmEnabled: boolean; groupDmChannels: string[]; defaultRequireMention: boolean; - channelsConfig?: Record< - string, - { - enabled?: boolean; - allow?: boolean; - requireMention?: boolean; - allowBots?: boolean; - users?: Array; - skills?: string[]; - systemPrompt?: string; - } - >; + channelsConfig?: SlackChannelConfigEntries; groupPolicy: GroupPolicy; useAccessGroups: boolean; reactionMode: SlackReactionNotificationMode;