mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-20 21:23:23 +00:00
fix: honor zalo default setup status
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
import type { OpenClawConfig } from "../runtime-api.js";
|
||||
import { zaloPlugin } from "./channel.js";
|
||||
import { zaloDmPolicy } from "./setup-core.js";
|
||||
import { zaloSetupWizard } from "./setup-surface.js";
|
||||
|
||||
const zaloConfigure = createPluginSetupWizardConfigure(zaloPlugin);
|
||||
|
||||
@@ -120,4 +121,27 @@ describe("zalo setup wizard", () => {
|
||||
expect(next.channels?.zalo?.accounts?.work?.dmPolicy).toBe("open");
|
||||
expect(next.channels?.zalo?.accounts?.work?.allowFrom).toEqual(["123456789", "*"]);
|
||||
});
|
||||
|
||||
it("uses configured defaultAccount for omitted setup configured state", async () => {
|
||||
const configured = await zaloSetupWizard.status.resolveConfigured({
|
||||
cfg: {
|
||||
channels: {
|
||||
zalo: {
|
||||
defaultAccount: "work",
|
||||
botToken: "root-token",
|
||||
accounts: {
|
||||
alerts: {
|
||||
botToken: "alerts-token",
|
||||
},
|
||||
work: {
|
||||
botToken: "",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig,
|
||||
});
|
||||
|
||||
expect(configured).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -185,19 +185,18 @@ export const zaloSetupWizard: ChannelSetupWizard = {
|
||||
configuredScore: 1,
|
||||
unconfiguredScore: 10,
|
||||
includeStatusLine: true,
|
||||
resolveConfigured: ({ cfg, accountId }) =>
|
||||
(accountId ? [accountId] : listZaloAccountIds(cfg)).some((resolvedAccountId) => {
|
||||
const account = resolveZaloAccount({
|
||||
cfg,
|
||||
accountId: resolvedAccountId,
|
||||
allowUnresolvedSecretRef: true,
|
||||
});
|
||||
return (
|
||||
Boolean(account.token) ||
|
||||
hasConfiguredSecretInput(account.config.botToken) ||
|
||||
Boolean(account.config.tokenFile?.trim())
|
||||
);
|
||||
}),
|
||||
resolveConfigured: ({ cfg, accountId }) => {
|
||||
const account = resolveZaloAccount({
|
||||
cfg,
|
||||
accountId,
|
||||
allowUnresolvedSecretRef: true,
|
||||
});
|
||||
return (
|
||||
Boolean(account.token) ||
|
||||
hasConfiguredSecretInput(account.config.botToken) ||
|
||||
Boolean(account.config.tokenFile?.trim())
|
||||
);
|
||||
},
|
||||
}),
|
||||
credentials: [],
|
||||
finalize: async ({ cfg, accountId, forceAllowFrom, options, prompter }) => {
|
||||
|
||||
Reference in New Issue
Block a user