mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-22 14:41:34 +00:00
This commit is contained in:
@@ -53,4 +53,55 @@ describe("discord audit", () => {
|
||||
expect(audit.channels[0]?.channelId).toBe("111");
|
||||
expect(audit.channels[0]?.missing).toContain("SendMessages");
|
||||
});
|
||||
|
||||
it("does not count '*' wildcard key as unresolved channel", async () => {
|
||||
const { collectDiscordAuditChannelIds } = await import("./audit.js");
|
||||
|
||||
const cfg = {
|
||||
channels: {
|
||||
discord: {
|
||||
enabled: true,
|
||||
token: "t",
|
||||
groupPolicy: "allowlist",
|
||||
guilds: {
|
||||
"123": {
|
||||
channels: {
|
||||
"111": { allow: true },
|
||||
"*": { allow: true },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as unknown as import("../config/config.js").OpenClawConfig;
|
||||
|
||||
const collected = collectDiscordAuditChannelIds({ cfg, accountId: "default" });
|
||||
expect(collected.channelIds).toEqual(["111"]);
|
||||
expect(collected.unresolvedChannels).toBe(0);
|
||||
});
|
||||
|
||||
it("handles guild with only '*' wildcard and no numeric channel ids", async () => {
|
||||
const { collectDiscordAuditChannelIds } = await import("./audit.js");
|
||||
|
||||
const cfg = {
|
||||
channels: {
|
||||
discord: {
|
||||
enabled: true,
|
||||
token: "t",
|
||||
groupPolicy: "allowlist",
|
||||
guilds: {
|
||||
"123": {
|
||||
channels: {
|
||||
"*": { allow: true },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as unknown as import("../config/config.js").OpenClawConfig;
|
||||
|
||||
const collected = collectDiscordAuditChannelIds({ cfg, accountId: "default" });
|
||||
expect(collected.channelIds).toEqual([]);
|
||||
expect(collected.unresolvedChannels).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -56,6 +56,11 @@ function listConfiguredGuildChannelKeys(
|
||||
if (!channelId) {
|
||||
continue;
|
||||
}
|
||||
// Skip wildcard keys (e.g. "*" meaning "all channels") — they are valid
|
||||
// config but are not real channel IDs and should not be audited.
|
||||
if (channelId === "*") {
|
||||
continue;
|
||||
}
|
||||
if (!shouldAuditChannelConfig(value as DiscordGuildChannelConfig | undefined)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user