refactor(channels): share legacy dm allowlist paths

This commit is contained in:
Peter Steinberger
2026-03-17 04:24:01 +00:00
parent 966b8656d2
commit 10660fe47d
4 changed files with 24 additions and 19 deletions

View File

@@ -1,5 +1,8 @@
import { Separator, TextDisplay } from "@buape/carbon";
import { buildAccountScopedAllowlistConfigEditor } from "openclaw/plugin-sdk/allowlist-config-edit";
import {
buildAccountScopedAllowlistConfigEditor,
resolveLegacyDmAllowlistConfigPaths,
} from "openclaw/plugin-sdk/allowlist-config-edit";
import {
buildAccountScopedDmSecurityPolicy,
collectOpenGroupPolicyConfiguredRouteWarnings,
@@ -347,14 +350,7 @@ export const discordPlugin: ChannelPlugin<ResolvedDiscordAccount> = {
channelId: "discord",
normalize: ({ cfg, accountId, values }) =>
discordConfigAccessors.formatAllowFrom!({ cfg, accountId, allowFrom: values }),
resolvePaths: (scope) =>
scope === "dm"
? {
readPaths: [["allowFrom"], ["dm", "allowFrom"]],
writePath: ["allowFrom"],
cleanupPaths: [["dm", "allowFrom"]],
}
: null,
resolvePaths: resolveLegacyDmAllowlistConfigPaths,
}),
},
security: {

View File

@@ -1,4 +1,7 @@
import { buildAccountScopedAllowlistConfigEditor } from "openclaw/plugin-sdk/allowlist-config-edit";
import {
buildAccountScopedAllowlistConfigEditor,
resolveLegacyDmAllowlistConfigPaths,
} from "openclaw/plugin-sdk/allowlist-config-edit";
import {
buildAccountScopedDmSecurityPolicy,
collectOpenGroupPolicyConfiguredRouteWarnings,
@@ -410,14 +413,7 @@ export const slackPlugin: ChannelPlugin<ResolvedSlackAccount> = {
channelId: "slack",
normalize: ({ cfg, accountId, values }) =>
slackConfigAccessors.formatAllowFrom!({ cfg, accountId, allowFrom: values }),
resolvePaths: (scope) =>
scope === "dm"
? {
readPaths: [["allowFrom"], ["dm", "allowFrom"]],
writePath: ["allowFrom"],
cleanupPaths: [["dm", "allowFrom"]],
}
: null,
resolvePaths: resolveLegacyDmAllowlistConfigPaths,
}),
},
security: {

View File

@@ -11,6 +11,16 @@ type AllowlistConfigPaths = {
cleanupPaths?: string[][];
};
const LEGACY_DM_ALLOWLIST_CONFIG_PATHS: AllowlistConfigPaths = {
readPaths: [["allowFrom"], ["dm", "allowFrom"]],
writePath: ["allowFrom"],
cleanupPaths: [["dm", "allowFrom"]],
};
export function resolveLegacyDmAllowlistConfigPaths(scope: "dm" | "group") {
return scope === "dm" ? LEGACY_DM_ALLOWLIST_CONFIG_PATHS : null;
}
function resolveAccountScopedWriteTarget(
parsed: Record<string, unknown>,
channelId: ChannelId,

View File

@@ -270,7 +270,10 @@ export { buildChannelSendResult } from "./channel-send-result.js";
export type { ChannelSendRawResult } from "./channel-send-result.js";
export { createPluginRuntimeStore } from "./runtime-store.js";
export { createScopedChannelConfigBase } from "./channel-config-helpers.js";
export { buildAccountScopedAllowlistConfigEditor } from "./allowlist-config-edit.js";
export {
buildAccountScopedAllowlistConfigEditor,
resolveLegacyDmAllowlistConfigPaths,
} from "./allowlist-config-edit.js";
export {
AllowFromEntrySchema,
AllowFromListSchema,