fix(discord): honor thread allowlists in reactions

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
Peter Steinberger
2026-01-17 22:39:09 +00:00
parent e63e483c38
commit 5aed38eebc
4 changed files with 101 additions and 19 deletions

View File

@@ -10,6 +10,8 @@ export type SlackChannelConfigResolved = {
users?: Array<string | number>;
skills?: string[];
systemPrompt?: string;
matchKey?: string;
matchSource?: "direct" | "wildcard";
};
function firstDefined<T>(...values: Array<T | undefined>) {
@@ -84,7 +86,12 @@ export function resolveSlackChannelConfig(params: {
directName,
normalizedName,
);
const { entry: matched, wildcardEntry: fallback } = resolveChannelEntryMatch({
const {
entry: matched,
key: matchedKey,
wildcardEntry: fallback,
wildcardKey,
} = resolveChannelEntryMatch({
entries,
keys: candidates,
wildcardKey: "*",
@@ -109,7 +116,22 @@ export function resolveSlackChannelConfig(params: {
const users = firstDefined(resolved.users, fallback?.users);
const skills = firstDefined(resolved.skills, fallback?.skills);
const systemPrompt = firstDefined(resolved.systemPrompt, fallback?.systemPrompt);
return { allowed, requireMention, allowBots, users, skills, systemPrompt };
const result: SlackChannelConfigResolved = {
allowed,
requireMention,
allowBots,
users,
skills,
systemPrompt,
};
if (matchedKey) {
result.matchKey = matchedKey;
result.matchSource = "direct";
} else if (wildcardKey && fallback) {
result.matchKey = wildcardKey;
result.matchSource = "wildcard";
}
return result;
}
export type { SlackMessageEvent };