fix: honor line default runtime account

This commit is contained in:
Tak Hoffman
2026-04-03 13:53:55 -05:00
parent 5e9ae0bfd4
commit 961d8eb095
2 changed files with 29 additions and 1 deletions

View File

@@ -103,6 +103,32 @@ describe("LINE accounts", () => {
expect(account.name).toBe("Business Bot");
});
it("uses configured defaultAccount when accountId is omitted", () => {
const cfg: OpenClawConfig = {
channels: {
line: {
defaultAccount: "business",
accounts: {
business: {
enabled: true,
channelAccessToken: "business-token",
channelSecret: "business-secret",
name: "Business Bot",
},
},
},
},
};
const account = resolveLineAccount({ cfg });
expect(account.accountId).toBe("business");
expect(account.enabled).toBe(true);
expect(account.channelAccessToken).toBe("business-token");
expect(account.channelSecret).toBe("business-secret");
expect(account.name).toBe("Business Bot");
});
it("returns empty token when not configured", () => {
const cfg: OpenClawConfig = {};

View File

@@ -94,7 +94,9 @@ export function resolveLineAccount(params: {
accountId?: string;
}): ResolvedLineAccount {
const cfg = params.cfg;
const accountId = normalizeSharedAccountId(params.accountId);
const accountId = normalizeSharedAccountId(
params.accountId ?? resolveDefaultLineAccountId(cfg),
);
const lineConfig = cfg.channels?.line as LineConfig | undefined;
const accounts = lineConfig?.accounts;
const accountConfig =