refactor: unify channel config matching and gating

Co-authored-by: thewilloftheshadow <thewilloftheshadow@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-01-18 01:21:27 +00:00
parent 05f49d2846
commit f73dbdbaea
24 changed files with 430 additions and 120 deletions

View File

@@ -2,7 +2,7 @@ import type { SlackReactionNotificationMode } from "../../config/config.js";
import type { SlackMessageEvent } from "../types.js";
import {
buildChannelKeyCandidates,
resolveChannelEntryMatch,
resolveChannelEntryMatchWithFallback,
} from "../../channels/channel-config.js";
import { allowListMatches, normalizeAllowListLower, normalizeSlackSlug } from "./allow-list.js";
@@ -91,10 +91,10 @@ export function resolveSlackChannelConfig(params: {
);
const {
entry: matched,
key: matchedKey,
wildcardEntry: fallback,
wildcardKey,
} = resolveChannelEntryMatch({
matchKey,
matchSource,
} = resolveChannelEntryMatchWithFallback({
entries,
keys: candidates,
wildcardKey: "*",
@@ -127,12 +127,9 @@ export function resolveSlackChannelConfig(params: {
skills,
systemPrompt,
};
if (matchedKey) {
result.matchKey = matchedKey;
result.matchSource = "direct";
} else if (wildcardKey && fallback) {
result.matchKey = wildcardKey;
result.matchSource = "wildcard";
if (matchKey) result.matchKey = matchKey;
if (matchSource === "direct" || matchSource === "wildcard") {
result.matchSource = matchSource;
}
return result;
}