refactor: share allowFrom stringification helpers

This commit is contained in:
Peter Steinberger
2026-03-07 23:24:45 +00:00
parent 99d14a820a
commit c5bd84309a
7 changed files with 16 additions and 16 deletions

View File

@@ -1,3 +1,4 @@
import { mapAllowFromEntries } from "../../plugin-sdk/channel-config-helpers.js";
import type { RuntimeEnv } from "../../runtime.js";
export type AllowlistUserResolutionLike = {
@@ -28,10 +29,7 @@ export function mergeAllowlist(params: {
existing?: Array<string | number>;
additions: string[];
}): string[] {
return dedupeAllowlistEntries([
...(params.existing ?? []).map((entry) => String(entry)),
...params.additions,
]);
return dedupeAllowlistEntries([...mapAllowFromEntries(params.existing), ...params.additions]);
}
export function buildAllowlistResolutionSummary<T extends AllowlistUserResolutionLike>(

View File

@@ -1,5 +1,6 @@
import type { OpenClawConfig } from "../../config/types.js";
import { inspectDiscordAccount } from "../../discord/account-inspect.js";
import { mapAllowFromEntries } from "../../plugin-sdk/channel-config-helpers.js";
import { inspectSlackAccount } from "../../slack/account-inspect.js";
import { inspectTelegramAccount } from "../../telegram/account-inspect.js";
import { resolveWhatsAppAccount } from "../../web/accounts.js";
@@ -161,7 +162,7 @@ export async function listTelegramDirectoryPeersFromConfig(
): Promise<ChannelDirectoryEntry[]> {
const account = inspectTelegramAccount({ cfg: params.cfg, accountId: params.accountId });
const raw = [
...(account.config.allowFrom ?? []).map((entry) => String(entry)),
...mapAllowFromEntries(account.config.allowFrom),
...Object.keys(account.config.dms ?? {}),
];
const ids = Array.from(