refactor(channels): pass setup input to mutator

This commit is contained in:
Peter Steinberger
2026-02-14 14:13:12 +00:00
parent f97ad8f288
commit 3150ece95a
2 changed files with 3 additions and 66 deletions

View File

@@ -21,37 +21,7 @@ export function applyChannelAccountConfig(params: {
cfg: OpenClawConfig;
channel: ChatChannel;
accountId: string;
name?: string;
token?: string;
tokenFile?: string;
botToken?: string;
appToken?: string;
signalNumber?: string;
cliPath?: string;
dbPath?: string;
service?: "imessage" | "sms" | "auto";
region?: string;
authDir?: string;
httpUrl?: string;
httpHost?: string;
httpPort?: string;
webhookPath?: string;
webhookUrl?: string;
audienceType?: string;
audience?: string;
useEnv?: boolean;
homeserver?: string;
userId?: string;
accessToken?: string;
password?: string;
deviceName?: string;
initialSyncLimit?: number;
ship?: string;
url?: string;
code?: string;
groupChannels?: string[];
dmAllowlist?: string[];
autoDiscoverChannels?: boolean;
input: ChannelSetupInput;
}): OpenClawConfig {
const accountId = normalizeAccountId(params.accountId);
const plugin = getChannelPlugin(params.channel);
@@ -59,38 +29,5 @@ export function applyChannelAccountConfig(params: {
if (!apply) {
return params.cfg;
}
const input: ChannelSetupInput = {
name: params.name,
token: params.token,
tokenFile: params.tokenFile,
botToken: params.botToken,
appToken: params.appToken,
signalNumber: params.signalNumber,
cliPath: params.cliPath,
dbPath: params.dbPath,
service: params.service,
region: params.region,
authDir: params.authDir,
httpUrl: params.httpUrl,
httpHost: params.httpHost,
httpPort: params.httpPort,
webhookPath: params.webhookPath,
webhookUrl: params.webhookUrl,
audienceType: params.audienceType,
audience: params.audience,
useEnv: params.useEnv,
homeserver: params.homeserver,
userId: params.userId,
accessToken: params.accessToken,
password: params.password,
deviceName: params.deviceName,
initialSyncLimit: params.initialSyncLimit,
ship: params.ship,
url: params.url,
code: params.code,
groupChannels: params.groupChannels,
dmAllowlist: params.dmAllowlist,
autoDiscoverChannels: params.autoDiscoverChannels,
};
return apply({ cfg: params.cfg, accountId, input });
return apply({ cfg: params.cfg, accountId, input: params.input });
}

View File

@@ -213,7 +213,7 @@ export async function channelsAddCommand(
cfg: nextConfig,
channel,
accountId,
...input,
input,
});
await writeConfigFile(nextConfig);