Discord: fix allowlist gating. Closes #961

This commit is contained in:
Shadow
2026-01-15 11:53:13 -06:00
parent 4de81ed6c4
commit 316e8b2eb2
7 changed files with 29 additions and 6 deletions

View File

@@ -197,13 +197,15 @@ export function resolveDiscordShouldRequireMention(params: {
export function isDiscordGroupAllowedByPolicy(params: {
groupPolicy: "open" | "disabled" | "allowlist";
guildAllowlisted: boolean;
channelAllowlistConfigured: boolean;
channelAllowed: boolean;
}): boolean {
const { groupPolicy, channelAllowlistConfigured, channelAllowed } = params;
const { groupPolicy, guildAllowlisted, channelAllowlistConfigured, channelAllowed } = params;
if (groupPolicy === "disabled") return false;
if (groupPolicy === "open") return true;
if (!channelAllowlistConfigured) return false;
if (!guildAllowlisted) return false;
if (!channelAllowlistConfigured) return true;
return channelAllowed;
}

View File

@@ -260,6 +260,7 @@ export async function preflightDiscordMessage(
isGuildMessage &&
!isDiscordGroupAllowedByPolicy({
groupPolicy: params.groupPolicy,
guildAllowlisted: Boolean(guildInfo),
channelAllowlistConfigured,
channelAllowed,
})

View File

@@ -448,6 +448,7 @@ async function dispatchDiscordCommandInteraction(params: {
const channelAllowed = channelConfig?.allowed !== false;
const allowByPolicy = isDiscordGroupAllowedByPolicy({
groupPolicy: discordConfig?.groupPolicy ?? "open",
guildAllowlisted: Boolean(guildInfo),
channelAllowlistConfigured,
channelAllowed,
});