refactor(channels): share channel config matching

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
Peter Steinberger
2026-01-17 22:30:37 +00:00
parent 277e43e32c
commit e63e483c38
7 changed files with 137 additions and 39 deletions

View File

@@ -9,6 +9,7 @@ import {
normalizeDiscordSlug,
registerDiscordListener,
resolveDiscordChannelConfig,
resolveDiscordChannelConfigWithFallback,
resolveDiscordGuildEntry,
resolveDiscordReplyTarget,
resolveDiscordShouldRequireMention,
@@ -160,6 +161,46 @@ describe("discord guild/channel resolution", () => {
});
expect(channel?.allowed).toBe(false);
});
it("inherits parent config for thread channels", () => {
const guildInfo: DiscordGuildEntryResolved = {
channels: {
general: { allow: true },
random: { allow: false },
},
};
const thread = resolveDiscordChannelConfigWithFallback({
guildInfo,
channelId: "thread-123",
channelName: "topic",
channelSlug: "topic",
parentId: "999",
parentName: "random",
parentSlug: "random",
scope: "thread",
});
expect(thread?.allowed).toBe(false);
});
it("does not match thread name/slug when resolving allowlists", () => {
const guildInfo: DiscordGuildEntryResolved = {
channels: {
general: { allow: true },
random: { allow: false },
},
};
const thread = resolveDiscordChannelConfigWithFallback({
guildInfo,
channelId: "thread-999",
channelName: "general",
channelSlug: "general",
parentId: "999",
parentName: "random",
parentSlug: "random",
scope: "thread",
});
expect(thread?.allowed).toBe(false);
});
});
describe("discord mention gating", () => {