refactor(onboarding): reuse allowlist merge across channels

This commit is contained in:
Peter Steinberger
2026-02-16 22:53:55 +00:00
parent 486b7379d4
commit 64f5e4a424
4 changed files with 28 additions and 29 deletions

View File

@@ -15,7 +15,7 @@ import {
resolveDefaultWhatsAppAccountId,
resolveWhatsAppAuthDir,
} from "../../../web/accounts.js";
import { promptAccountId } from "./helpers.js";
import { mergeAllowFromEntries, promptAccountId } from "./helpers.js";
const channel = "whatsapp" as const;
@@ -72,10 +72,10 @@ async function promptWhatsAppOwnerAllowFrom(params: {
...existingAllowFrom
.filter((item) => item !== "*")
.map((item) => normalizeE164(item))
.filter(Boolean),
.filter((item): item is string => typeof item === "string" && item.trim().length > 0),
normalized,
];
const allowFrom = [...new Set(merged.filter(Boolean))];
const allowFrom = mergeAllowFromEntries(undefined, merged);
return { normalized, allowFrom };
}
@@ -234,8 +234,10 @@ async function promptWhatsAppAllowFrom(
.split(/[\n,;]+/g)
.map((p) => p.trim())
.filter(Boolean);
const normalized = parts.map((part) => (part === "*" ? "*" : normalizeE164(part)));
const unique = [...new Set(normalized.filter(Boolean))];
const normalized = parts
.map((part) => (part === "*" ? "*" : normalizeE164(part)))
.filter((part): part is string => typeof part === "string" && part.trim().length > 0);
const unique = mergeAllowFromEntries(undefined, normalized);
next = setWhatsAppAllowFrom(next, unique);
}