This commit is contained in:
wakingcan 2026-01-30 16:10:04 +08:00 committed by GitHub
commit a86cdd4fa4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -258,7 +258,8 @@ export function resolveDiscordChannelConfigWithFallback(params: {
scope,
} = params;
const channels = guildInfo?.channels;
if (!channels) return null;
// Return null if channels is undefined, null, or empty object - allows all channels when no allowlist is configured
if (!channels || Object.keys(channels).length === 0) return null;
const resolvedParentSlug = parentSlug ?? (parentName ? normalizeDiscordSlug(parentName) : "");
const match = resolveDiscordChannelEntryMatch(
channels,

View File

@ -38,6 +38,7 @@ import {
readChannelAllowFromStore,
upsertChannelPairingRequest,
} from "../../pairing/pairing-store.js";
import { logVerbose } from "../../globals.js";
import { resolveAgentRoute } from "../../routing/resolve-route.js";
import { loadWebMedia } from "../../web/media.js";
import { chunkDiscordTextWithMode } from "../chunk.js";
@ -656,6 +657,14 @@ async function dispatchDiscordCommandInteraction(params: {
modeWhenAccessGroupsOff: "configured",
});
if (!commandAuthorized) {
// Log warning when no allowlist is configured to help users debug
const anyAuthorizerConfigured = authorizers.some((entry) => entry.configured);
if (!anyAuthorizerConfigured) {
logVerbose(
`discord: slash command rejected for user ${user.id} - no allowlist configured. ` +
`Configure channels.discord.guilds.<id>.users or channels.discord.dm.allowFrom to allow users.`,
);
}
await respond("You are not authorized to use this command.", { ephemeral: true });
return;
}