fix: honor feishu setup adapter default

This commit is contained in:
Tak Hoffman
2026-04-03 13:14:10 -05:00
parent a89cb679a2
commit d20e3d5691
2 changed files with 24 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ import {
type ChannelSetupAdapter,
type OpenClawConfig,
} from "openclaw/plugin-sdk/setup";
import { resolveDefaultFeishuAccountId } from "./accounts.js";
import type { FeishuConfig } from "./types.js";
export function setFeishuNamedAccountEnabled(
@@ -30,7 +31,7 @@ export function setFeishuNamedAccountEnabled(
}
export const feishuSetupAdapter: ChannelSetupAdapter = {
resolveAccountId: ({ accountId }) => accountId?.trim() || DEFAULT_ACCOUNT_ID,
resolveAccountId: ({ cfg, accountId }) => accountId?.trim() || resolveDefaultFeishuAccountId(cfg),
applyAccountConfig: ({ cfg, accountId }) => {
const isDefault = !accountId || accountId === DEFAULT_ACCOUNT_ID;
if (isDefault) {

View File

@@ -71,6 +71,28 @@ describe("feishu setup wizard", () => {
).toBe("work");
});
it("setup adapter uses configured defaultAccount when accountId is omitted", () => {
expect(
feishuPlugin.setup?.resolveAccountId?.({
cfg: {
channels: {
feishu: {
defaultAccount: "work",
accounts: {
work: {
appId: "work-app",
appSecret: "work-secret", // pragma: allowlist secret
},
},
},
},
} as never,
accountId: undefined,
input: {},
} as never),
).toBe("work");
});
it("does not throw when config appId/appSecret are SecretRef objects", async () => {
const text = vi
.fn()