fix(channels): add optional defaultAccount routing

This commit is contained in:
Peter Steinberger
2026-03-02 04:03:13 +00:00
parent 0437ac1a89
commit 41537e9303
45 changed files with 461 additions and 35 deletions

View File

@@ -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 { GoogleChatAccountConfig } from "./types.config.js";
export type GoogleChatCredentialSource = "file" | "inline" | "env" | "none";
@@ -35,8 +39,12 @@ export function listGoogleChatAccountIds(cfg: OpenClawConfig): string[] {
export function resolveDefaultGoogleChatAccountId(cfg: OpenClawConfig): string {
const channel = cfg.channels?.["googlechat"];
if (channel?.defaultAccount?.trim()) {
return channel.defaultAccount.trim();
const preferred = normalizeOptionalAccountId(channel?.defaultAccount);
if (
preferred &&
listGoogleChatAccountIds(cfg).some((accountId) => normalizeAccountId(accountId) === preferred)
) {
return preferred;
}
const ids = listGoogleChatAccountIds(cfg);
if (ids.includes(DEFAULT_ACCOUNT_ID)) {