From 4d2e9e8113a1cad52c5b463f1eefda8b1750acbd Mon Sep 17 00:00:00 2001 From: Jay Winder Date: Sat, 24 Jan 2026 15:03:35 +0900 Subject: [PATCH] fix(slack): apply open policy consistently to slash commands Address reviewer feedback: slash commands now use the same hasExplicitConfig check as regular messages, so unlisted channels are allowed under groupPolicy: "open" for both message handling and slash commands. --- src/slack/monitor/slash.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/slack/monitor/slash.ts b/src/slack/monitor/slash.ts index 8f290d892..decd55e59 100644 --- a/src/slack/monitor/slash.ts +++ b/src/slack/monitor/slash.ts @@ -262,8 +262,7 @@ export function registerSlackMonitorSlashCommands(params: { groupPolicy: ctx.groupPolicy, channelAllowlistConfigured, channelAllowed, - }) || - !channelAllowed + }) ) { await respond({ text: "This channel is not allowed.", @@ -271,13 +270,17 @@ export function registerSlackMonitorSlashCommands(params: { }); return; } - } - if (ctx.useAccessGroups && channelConfig?.allowed === false) { - await respond({ - text: "This channel is not allowed.", - response_type: "ephemeral", - }); - return; + // When groupPolicy is "open", only block channels that are EXPLICITLY denied + // (i.e., have a matching config entry with allow:false). Channels not in the + // config (matchSource undefined) should be allowed under open policy. + const hasExplicitConfig = Boolean(channelConfig?.matchSource); + if (!channelAllowed && (ctx.groupPolicy !== "open" || hasExplicitConfig)) { + await respond({ + text: "This channel is not allowed.", + response_type: "ephemeral", + }); + return; + } } }