mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-23 22:55:24 +00:00
refactor(channels): share legacy dm allowlist paths
This commit is contained in:
@@ -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: {
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user