refactor: share config adapter allowFrom and defaultTo helpers

This commit is contained in:
Peter Steinberger
2026-03-07 23:02:59 +00:00
parent feac26c3b7
commit 556aa8a702
17 changed files with 100 additions and 57 deletions

View File

@@ -1,4 +1,4 @@
import { buildAccountScopedDmSecurityPolicy } from "openclaw/plugin-sdk";
import { buildAccountScopedDmSecurityPolicy, mapAllowFromEntries } from "openclaw/plugin-sdk";
import type {
ChannelAccountSnapshot,
ChannelDirectoryEntry,
@@ -208,9 +208,7 @@ export const zalouserDock: ChannelDock = {
outbound: { textChunkLimit: 2000 },
config: {
resolveAllowFrom: ({ cfg, accountId }) =>
(resolveZalouserAccountSync({ cfg: cfg, accountId }).config.allowFrom ?? []).map((entry) =>
String(entry),
),
mapAllowFromEntries(resolveZalouserAccountSync({ cfg: cfg, accountId }).config.allowFrom),
formatAllowFrom: ({ allowFrom }) =>
formatAllowFromLowercase({ allowFrom, stripPrefixRe: /^(zalouser|zlu):/i }),
},
@@ -273,9 +271,7 @@ export const zalouserPlugin: ChannelPlugin<ResolvedZalouserAccount> = {
configured: undefined,
}),
resolveAllowFrom: ({ cfg, accountId }) =>
(resolveZalouserAccountSync({ cfg: cfg, accountId }).config.allowFrom ?? []).map((entry) =>
String(entry),
),
mapAllowFromEntries(resolveZalouserAccountSync({ cfg: cfg, accountId }).config.allowFrom),
formatAllowFrom: ({ allowFrom }) =>
formatAllowFromLowercase({ allowFrom, stripPrefixRe: /^(zalouser|zlu):/i }),
},