From 4956271da10f1621806faa583e7aa8099fb3ec37 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 7 Mar 2026 23:26:16 +0000 Subject: [PATCH] refactor: share provider allowlist input normalization --- src/discord/monitor/provider.allowlist.ts | 6 +++--- src/slack/monitor/provider.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/discord/monitor/provider.allowlist.ts b/src/discord/monitor/provider.allowlist.ts index b4e744af6..e1f52c0c3 100644 --- a/src/discord/monitor/provider.allowlist.ts +++ b/src/discord/monitor/provider.allowlist.ts @@ -8,6 +8,7 @@ import { import type { DiscordGuildEntry } from "../../config/types.discord.js"; import { formatErrorMessage } from "../../infra/errors.js"; import type { RuntimeEnv } from "../../runtime.js"; +import { normalizeStringEntries } from "../../shared/string-normalization.js"; import { resolveDiscordChannelAllowlist } from "../resolve-channels.js"; import { resolveDiscordUserAllowlist } from "../resolve-users.js"; @@ -205,15 +206,14 @@ async function resolveAllowFromByUserAllowlist(params: { fetcher: typeof fetch; runtime: RuntimeEnv; }): Promise { - const allowEntries = - params.allowFrom?.filter((entry) => String(entry).trim() && String(entry).trim() !== "*") ?? []; + const allowEntries = normalizeStringEntries(params.allowFrom).filter((entry) => entry !== "*"); if (allowEntries.length === 0) { return params.allowFrom; } try { const resolvedUsers = await resolveDiscordUserAllowlist({ token: params.token, - entries: allowEntries.map((entry) => String(entry)), + entries: allowEntries, fetcher: params.fetcher, }); const { resolvedMap, mapping, unresolved } = buildAllowlistResolutionSummary(resolvedUsers, { diff --git a/src/slack/monitor/provider.ts b/src/slack/monitor/provider.ts index 8686eb513..3db3d3690 100644 --- a/src/slack/monitor/provider.ts +++ b/src/slack/monitor/provider.ts @@ -24,6 +24,7 @@ import { computeBackoff, sleepWithAbort } from "../../infra/backoff.js"; import { installRequestBodyLimitGuard } from "../../infra/http-body.js"; import { normalizeMainKey } from "../../routing/session-key.js"; import { createNonExitingRuntime, type RuntimeEnv } from "../../runtime.js"; +import { normalizeStringEntries } from "../../shared/string-normalization.js"; import { resolveSlackAccount } from "../accounts.js"; import { resolveSlackWebClientOptions } from "../client.js"; import { normalizeSlackWebhookPath, registerSlackHttpHandler } from "../http/index.js"; @@ -345,13 +346,12 @@ export async function monitorSlackProvider(opts: MonitorSlackOpts = {}) { } } - const allowEntries = - allowFrom?.filter((entry) => String(entry).trim() && String(entry).trim() !== "*") ?? []; + const allowEntries = normalizeStringEntries(allowFrom).filter((entry) => entry !== "*"); if (allowEntries.length > 0) { try { const resolvedUsers = await resolveSlackUserAllowlist({ token: resolveToken, - entries: allowEntries.map((entry) => String(entry)), + entries: allowEntries, }); const { mapping, unresolved, additions } = buildAllowlistResolutionSummary( resolvedUsers,