Feishu: honor configured default account

This commit is contained in:
bmendonca3
2026-03-01 00:59:57 -07:00
committed by Peter Steinberger
parent ddd71bc9f6
commit 4e4a100038
2 changed files with 19 additions and 4 deletions

View File

@@ -33,11 +33,26 @@ describe("resolveDefaultFeishuAccountId", () => {
expect(resolveDefaultFeishuAccountId(cfg as never)).toBe("router-d");
});
it("falls back to literal default account id when preferred is missing", () => {
it("keeps configured defaultAccount even when not present in accounts map", () => {
const cfg = {
channels: {
feishu: {
defaultAccount: "router-d",
accounts: {
default: { appId: "cli_default", appSecret: "secret_default" },
zeta: { appId: "cli_zeta", appSecret: "secret_zeta" },
},
},
},
};
expect(resolveDefaultFeishuAccountId(cfg as never)).toBe("router-d");
});
it("falls back to literal default account id when present", () => {
const cfg = {
channels: {
feishu: {
defaultAccount: "missing",
accounts: {
default: { appId: "cli_default", appSecret: "secret_default" },
zeta: { appId: "cli_zeta", appSecret: "secret_zeta" },

View File

@@ -37,10 +37,10 @@ export function listFeishuAccountIds(cfg: ClawdbotConfig): string[] {
export function resolveDefaultFeishuAccountId(cfg: ClawdbotConfig): string {
const preferredRaw = (cfg.channels?.feishu as FeishuConfig | undefined)?.defaultAccount?.trim();
const preferred = preferredRaw ? normalizeAccountId(preferredRaw) : undefined;
const ids = listFeishuAccountIds(cfg);
if (preferred && ids.includes(preferred)) {
if (preferred) {
return preferred;
}
const ids = listFeishuAccountIds(cfg);
if (ids.includes(DEFAULT_ACCOUNT_ID)) {
return DEFAULT_ACCOUNT_ID;
}