refactor(channels): share channel config matching
Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user