mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 10:27:38 +00:00
fix(channels): add optional defaultAccount routing
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk";
|
||||
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "openclaw/plugin-sdk/account-id";
|
||||
import {
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
normalizeAccountId,
|
||||
normalizeOptionalAccountId,
|
||||
} from "openclaw/plugin-sdk/account-id";
|
||||
import type { ResolvedZalouserAccount, ZalouserAccountConfig, ZalouserConfig } from "./types.js";
|
||||
import { runZca, parseJsonOutput } from "./zca.js";
|
||||
|
||||
@@ -21,8 +25,12 @@ export function listZalouserAccountIds(cfg: OpenClawConfig): string[] {
|
||||
|
||||
export function resolveDefaultZalouserAccountId(cfg: OpenClawConfig): string {
|
||||
const zalouserConfig = cfg.channels?.zalouser as ZalouserConfig | undefined;
|
||||
if (zalouserConfig?.defaultAccount?.trim()) {
|
||||
return zalouserConfig.defaultAccount.trim();
|
||||
const preferred = normalizeOptionalAccountId(zalouserConfig?.defaultAccount);
|
||||
if (
|
||||
preferred &&
|
||||
listZalouserAccountIds(cfg).some((accountId) => normalizeAccountId(accountId) === preferred)
|
||||
) {
|
||||
return preferred;
|
||||
}
|
||||
const ids = listZalouserAccountIds(cfg);
|
||||
if (ids.includes(DEFAULT_ACCOUNT_ID)) {
|
||||
|
||||
Reference in New Issue
Block a user