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

@@ -5,6 +5,7 @@ import type { MonitorSlackOpts } from "./types.js";
import { resolveTextChunkLimit } from "../../auto-reply/chunk.js";
import { DEFAULT_GROUP_HISTORY_LIMIT } from "../../auto-reply/reply/history.js";
import {
addAllowlistUserEntriesFromConfigEntry,
buildAllowlistResolutionSummary,
mergeAllowlist,
patchAllowlistUsersInConfigEntries,
@@ -305,19 +306,7 @@ export async function monitorSlackProvider(opts: MonitorSlackOpts = {}) {
if (channelsConfig && Object.keys(channelsConfig).length > 0) {
const userEntries = new Set<string>();
for (const channel of Object.values(channelsConfig)) {
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);
}
if (userEntries.size > 0) {