Config: require Discord ID strings (#18220)

This commit is contained in:
Shadow
2026-02-16 12:22:58 -06:00
committed by GitHub
parent 5d40d47501
commit 1b7301051b
12 changed files with 371 additions and 43 deletions

View File

@@ -17,14 +17,23 @@ import { resolveDiscordUserAllowlist } from "../../../discord/resolve-users.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../routing/session-key.js";
import { formatDocsLink } from "../../../terminal/links.js";
import { promptChannelAccessConfig } from "./channel-access.js";
import { addWildcardAllowFrom, promptAccountId } from "./helpers.js";
import { promptAccountId } from "./helpers.js";
function addDiscordWildcardAllowFrom(allowFrom?: string[] | null): string[] {
const next = (allowFrom ?? []).map((entry) => entry.trim()).filter(Boolean);
if (!next.includes("*")) {
next.push("*");
}
return next;
}
const channel = "discord" as const;
function setDiscordDmPolicy(cfg: OpenClawConfig, dmPolicy: DmPolicy) {
const existingAllowFrom =
cfg.channels?.discord?.allowFrom ?? cfg.channels?.discord?.dm?.allowFrom;
const allowFrom = dmPolicy === "open" ? addWildcardAllowFrom(existingAllowFrom) : undefined;
const allowFrom =
dmPolicy === "open" ? addDiscordWildcardAllowFrom(existingAllowFrom) : undefined;
return {
...cfg,
channels: {