mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 08:40:22 +00:00
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import {
|
|
DEFAULT_ACCOUNT_ID,
|
|
resolveAccountEntry,
|
|
resolveMergedAccountConfig,
|
|
type OpenClawConfig,
|
|
} from "openclaw/plugin-sdk/account-core";
|
|
import type { WhatsAppAccountConfig } from "./runtime-api.js";
|
|
|
|
function resolveWhatsAppAccountConfig(
|
|
cfg: OpenClawConfig,
|
|
accountId: string,
|
|
): WhatsAppAccountConfig | undefined {
|
|
return resolveAccountEntry(cfg.channels?.whatsapp?.accounts, accountId);
|
|
}
|
|
|
|
export function resolveMergedWhatsAppAccountConfig(params: {
|
|
cfg: OpenClawConfig;
|
|
accountId?: string | null;
|
|
}): WhatsAppAccountConfig & { accountId: string } {
|
|
const rootCfg = params.cfg.channels?.whatsapp;
|
|
const accountId = params.accountId?.trim() || rootCfg?.defaultAccount || DEFAULT_ACCOUNT_ID;
|
|
const merged = resolveMergedAccountConfig<WhatsAppAccountConfig>({
|
|
channelConfig: rootCfg as WhatsAppAccountConfig | undefined,
|
|
accounts: rootCfg?.accounts as Record<string, Partial<WhatsAppAccountConfig>> | undefined,
|
|
accountId,
|
|
omitKeys: ["defaultAccount"],
|
|
});
|
|
return {
|
|
accountId,
|
|
...merged,
|
|
};
|
|
}
|