mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-28 21:01:43 +03:00
refactor(channels): pass setup input to mutator
This commit is contained in:
@@ -21,37 +21,7 @@ export function applyChannelAccountConfig(params: {
|
|||||||
cfg: OpenClawConfig;
|
cfg: OpenClawConfig;
|
||||||
channel: ChatChannel;
|
channel: ChatChannel;
|
||||||
accountId: string;
|
accountId: string;
|
||||||
name?: string;
|
input: ChannelSetupInput;
|
||||||
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;
|
|
||||||
}): OpenClawConfig {
|
}): OpenClawConfig {
|
||||||
const accountId = normalizeAccountId(params.accountId);
|
const accountId = normalizeAccountId(params.accountId);
|
||||||
const plugin = getChannelPlugin(params.channel);
|
const plugin = getChannelPlugin(params.channel);
|
||||||
@@ -59,38 +29,5 @@ export function applyChannelAccountConfig(params: {
|
|||||||
if (!apply) {
|
if (!apply) {
|
||||||
return params.cfg;
|
return params.cfg;
|
||||||
}
|
}
|
||||||
const input: ChannelSetupInput = {
|
return apply({ cfg: params.cfg, accountId, input: params.input });
|
||||||
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 });
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ export async function channelsAddCommand(
|
|||||||
cfg: nextConfig,
|
cfg: nextConfig,
|
||||||
channel,
|
channel,
|
||||||
accountId,
|
accountId,
|
||||||
...input,
|
input,
|
||||||
});
|
});
|
||||||
|
|
||||||
await writeConfigFile(nextConfig);
|
await writeConfigFile(nextConfig);
|
||||||
|
|||||||
Reference in New Issue
Block a user