mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-06 14:51:08 +00:00
fix: honor bluebubbles default account setup policy
This commit is contained in:
@@ -185,6 +185,37 @@ describe("bluebubbles setup surface", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("uses configured defaultAccount for omitted DM policy account context", async () => {
|
||||
const { blueBubblesSetupWizard } = await import("./setup-surface.js");
|
||||
|
||||
const cfg = {
|
||||
channels: {
|
||||
bluebubbles: {
|
||||
defaultAccount: "work",
|
||||
dmPolicy: "disabled",
|
||||
allowFrom: ["user@example.com"],
|
||||
accounts: {
|
||||
work: {
|
||||
serverUrl: "http://localhost:1234",
|
||||
password: "secret",
|
||||
dmPolicy: "allowlist",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
|
||||
expect(blueBubblesSetupWizard.dmPolicy?.getCurrent(cfg)).toBe("allowlist");
|
||||
expect(blueBubblesSetupWizard.dmPolicy?.resolveConfigKeys?.(cfg)).toEqual({
|
||||
policyKey: "channels.bluebubbles.accounts.work.dmPolicy",
|
||||
allowFromKey: "channels.bluebubbles.accounts.work.allowFrom",
|
||||
});
|
||||
|
||||
const next = blueBubblesSetupWizard.dmPolicy?.setPolicy(cfg, "open");
|
||||
expect(next?.channels?.bluebubbles?.dmPolicy).toBe("disabled");
|
||||
expect(next?.channels?.bluebubbles?.accounts?.work?.dmPolicy).toBe("open");
|
||||
});
|
||||
|
||||
it('writes open policy state to the named account and preserves inherited allowFrom with "*"', async () => {
|
||||
const { blueBubblesSetupWizard } = await import("./setup-surface.js");
|
||||
|
||||
|
||||
@@ -135,21 +135,28 @@ const dmPolicy: ChannelSetupDmPolicy = {
|
||||
channel,
|
||||
policyKey: "channels.bluebubbles.dmPolicy",
|
||||
allowFromKey: "channels.bluebubbles.allowFrom",
|
||||
resolveConfigKeys: (_cfg, accountId) =>
|
||||
accountId && accountId !== DEFAULT_ACCOUNT_ID
|
||||
resolveConfigKeys: (cfg, accountId) =>
|
||||
(accountId ?? resolveDefaultBlueBubblesAccountId(cfg)) !== DEFAULT_ACCOUNT_ID
|
||||
? {
|
||||
policyKey: `channels.bluebubbles.accounts.${accountId}.dmPolicy`,
|
||||
allowFromKey: `channels.bluebubbles.accounts.${accountId}.allowFrom`,
|
||||
policyKey: `channels.bluebubbles.accounts.${accountId ?? resolveDefaultBlueBubblesAccountId(cfg)}.dmPolicy`,
|
||||
allowFromKey: `channels.bluebubbles.accounts.${accountId ?? resolveDefaultBlueBubblesAccountId(cfg)}.allowFrom`,
|
||||
}
|
||||
: {
|
||||
policyKey: "channels.bluebubbles.dmPolicy",
|
||||
allowFromKey: "channels.bluebubbles.allowFrom",
|
||||
},
|
||||
getCurrent: (cfg, accountId) =>
|
||||
resolveBlueBubblesAccount({ cfg, accountId: accountId ?? DEFAULT_ACCOUNT_ID }).config
|
||||
resolveBlueBubblesAccount({
|
||||
cfg,
|
||||
accountId: accountId ?? resolveDefaultBlueBubblesAccountId(cfg),
|
||||
}).config
|
||||
.dmPolicy ?? "pairing",
|
||||
setPolicy: (cfg, policy, accountId) =>
|
||||
setBlueBubblesDmPolicy(cfg, accountId ?? DEFAULT_ACCOUNT_ID, policy),
|
||||
setBlueBubblesDmPolicy(
|
||||
cfg,
|
||||
accountId ?? resolveDefaultBlueBubblesAccountId(cfg),
|
||||
policy,
|
||||
),
|
||||
promptAllowFrom: promptBlueBubblesAllowFrom,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user