mirror of https://github.com/openclaw/openclaw.git
refactor: share zalouser account resolution
This commit is contained in:
parent
7235ee55c6
commit
a6375a2094
|
|
@ -43,17 +43,24 @@ function resolveProfile(config: ZalouserAccountConfig, accountId: string): strin
|
||||||
return "default";
|
return "default";
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function resolveZalouserAccount(params: {
|
function resolveZalouserAccountBase(params: { cfg: OpenClawConfig; accountId?: string | null }) {
|
||||||
cfg: OpenClawConfig;
|
|
||||||
accountId?: string | null;
|
|
||||||
}): Promise<ResolvedZalouserAccount> {
|
|
||||||
const accountId = normalizeAccountId(params.accountId);
|
const accountId = normalizeAccountId(params.accountId);
|
||||||
const baseEnabled =
|
const baseEnabled =
|
||||||
(params.cfg.channels?.zalouser as ZalouserConfig | undefined)?.enabled !== false;
|
(params.cfg.channels?.zalouser as ZalouserConfig | undefined)?.enabled !== false;
|
||||||
const merged = mergeZalouserAccountConfig(params.cfg, accountId);
|
const merged = mergeZalouserAccountConfig(params.cfg, accountId);
|
||||||
const accountEnabled = merged.enabled !== false;
|
return {
|
||||||
const enabled = baseEnabled && accountEnabled;
|
accountId,
|
||||||
const profile = resolveProfile(merged, accountId);
|
enabled: baseEnabled && merged.enabled !== false,
|
||||||
|
merged,
|
||||||
|
profile: resolveProfile(merged, accountId),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function resolveZalouserAccount(params: {
|
||||||
|
cfg: OpenClawConfig;
|
||||||
|
accountId?: string | null;
|
||||||
|
}): Promise<ResolvedZalouserAccount> {
|
||||||
|
const { accountId, enabled, merged, profile } = resolveZalouserAccountBase(params);
|
||||||
const authenticated = await checkZaloAuthenticated(profile);
|
const authenticated = await checkZaloAuthenticated(profile);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -70,13 +77,7 @@ export function resolveZalouserAccountSync(params: {
|
||||||
cfg: OpenClawConfig;
|
cfg: OpenClawConfig;
|
||||||
accountId?: string | null;
|
accountId?: string | null;
|
||||||
}): ResolvedZalouserAccount {
|
}): ResolvedZalouserAccount {
|
||||||
const accountId = normalizeAccountId(params.accountId);
|
const { accountId, enabled, merged, profile } = resolveZalouserAccountBase(params);
|
||||||
const baseEnabled =
|
|
||||||
(params.cfg.channels?.zalouser as ZalouserConfig | undefined)?.enabled !== false;
|
|
||||||
const merged = mergeZalouserAccountConfig(params.cfg, accountId);
|
|
||||||
const accountEnabled = merged.enabled !== false;
|
|
||||||
const enabled = baseEnabled && accountEnabled;
|
|
||||||
const profile = resolveProfile(merged, accountId);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
accountId,
|
accountId,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue