fix: honor googlechat default runtime account

This commit is contained in:
Tak Hoffman
2026-04-03 13:22:07 -05:00
parent 28b8e019f7
commit 5c3dc40794
2 changed files with 23 additions and 1 deletions

View File

@@ -130,7 +130,9 @@ export function resolveGoogleChatAccount(params: {
cfg: OpenClawConfig;
accountId?: string | null;
}): ResolvedGoogleChatAccount {
const accountId = normalizeAccountId(params.accountId);
const accountId = normalizeAccountId(
params.accountId ?? params.cfg.channels?.["googlechat"]?.defaultAccount,
);
const baseEnabled = params.cfg.channels?.["googlechat"]?.enabled !== false;
const merged = mergeGoogleChatAccountConfig(params.cfg, accountId);
const accountEnabled = merged.enabled !== false;

View File

@@ -489,4 +489,24 @@ describe("resolveGoogleChatAccount", () => {
expect(resolved.config.dangerouslyAllowNameMatching).toBeUndefined();
expect(resolved.config.audienceType).toBe("app-url");
});
it("uses configured defaultAccount when accountId is omitted", () => {
const cfg: OpenClawConfig = {
channels: {
googlechat: {
defaultAccount: "alerts",
accounts: {
alerts: {
serviceAccountFile: "/tmp/alerts-sa.json",
},
},
},
},
};
const resolved = resolveGoogleChatAccount({ cfg });
expect(resolved.accountId).toBe("alerts");
expect(resolved.credentialSource).toBe("file");
expect(resolved.credentialsFile).toBe("/tmp/alerts-sa.json");
});
});