refactor(allowlists): share user entry collection

This commit is contained in:
Peter Steinberger
2026-02-15 17:45:16 +00:00
parent 04f00f8ef2
commit 1f1e97674f
4 changed files with 39 additions and 36 deletions

View File

@@ -8,6 +8,7 @@ import { resolveTextChunkLimit } from "../../auto-reply/chunk.js";
import { listNativeCommandSpecsForConfig } from "../../auto-reply/commands-registry.js";
import { listSkillCommandsForAgents } from "../../auto-reply/skill-commands.js";
import {
addAllowlistUserEntriesFromConfigEntry,
buildAllowlistResolutionSummary,
mergeAllowlist,
resolveAllowlistIdAdditions,
@@ -294,30 +295,10 @@ export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) {
if (!guild || typeof guild !== "object") {
continue;
}
const users = (guild as { users?: Array<string | number> }).users;
if (Array.isArray(users)) {
for (const entry of users) {
const trimmed = String(entry).trim();
if (trimmed && trimmed !== "*") {
userEntries.add(trimmed);
}
}
}
addAllowlistUserEntriesFromConfigEntry(userEntries, guild);
const channels = (guild as { channels?: Record<string, unknown> }).channels ?? {};
for (const channel of Object.values(channels)) {
if (!channel || typeof channel !== "object") {
continue;
}
const channelUsers = (channel as { users?: Array<string | number> }).users;
if (!Array.isArray(channelUsers)) {
continue;
}
for (const entry of channelUsers) {
const trimmed = String(entry).trim();
if (trimmed && trimmed !== "*") {
userEntries.add(trimmed);
}
}
addAllowlistUserEntriesFromConfigEntry(userEntries, channel);
}
}