refactor(channels): share allowlist resolution summary

This commit is contained in:
Peter Steinberger
2026-02-15 17:26:27 +00:00
parent 63ab5bfddc
commit 25be51967a
4 changed files with 50 additions and 28 deletions

View File

@@ -283,18 +283,17 @@ export async function monitorSlackProvider(opts: MonitorSlackOpts = {}) {
token: resolveToken,
entries: allowEntries.map((entry) => String(entry)),
});
const mapping: string[] = [];
const unresolved: string[] = [];
const additions: string[] = [];
for (const entry of resolvedUsers) {
if (entry.resolved && entry.id) {
const note = entry.note ? ` (${entry.note})` : "";
mapping.push(`${entry.input}${entry.id}${note}`);
additions.push(entry.id);
} else {
unresolved.push(entry.input);
}
}
const { mapping, unresolved, additions } = buildAllowlistResolutionSummary(
resolvedUsers,
{
formatResolved: (entry) => {
const note = (entry as { note?: string }).note
? ` (${(entry as { note?: string }).note})`
: "";
return `${entry.input}${entry.id}${note}`;
},
},
);
allowFrom = mergeAllowlist({ existing: allowFrom, additions });
ctx.allowFrom = normalizeAllowList(allowFrom);
summarizeMapping("slack users", mapping, unresolved, runtime);