refactor(zalouser): reuse patched setup adapter

This commit is contained in:
Peter Steinberger 2026-03-17 03:44:10 +00:00
parent 7fc134d74e
commit 81ef52a81e

View File

@ -1,43 +1,9 @@
import {
applyAccountNameToChannelSection,
applySetupAccountConfigPatch,
DEFAULT_ACCOUNT_ID,
migrateBaseNameToDefaultAccount,
normalizeAccountId,
type ChannelSetupAdapter,
} from "openclaw/plugin-sdk/setup";
import { createPatchedAccountSetupAdapter } from "../../../src/channels/plugins/setup-helpers.js";
const channel = "zalouser" as const;
export const zalouserSetupAdapter: ChannelSetupAdapter = {
resolveAccountId: ({ accountId }) => normalizeAccountId(accountId),
applyAccountName: ({ cfg, accountId, name }) =>
applyAccountNameToChannelSection({
cfg,
channelKey: channel,
accountId,
name,
}),
export const zalouserSetupAdapter = createPatchedAccountSetupAdapter({
channelKey: channel,
validateInput: () => null,
applyAccountConfig: ({ cfg, accountId, input }) => {
const namedConfig = applyAccountNameToChannelSection({
cfg,
channelKey: channel,
accountId,
name: input.name,
});
const next =
accountId !== DEFAULT_ACCOUNT_ID
? migrateBaseNameToDefaultAccount({
cfg: namedConfig,
channelKey: channel,
})
: namedConfig;
return applySetupAccountConfigPatch({
cfg: next,
channelKey: channel,
accountId,
patch: {},
});
},
};
buildPatch: () => ({}),
});