mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-06 06:41:08 +00:00
fix: honor bluebubbles action discovery account config
This commit is contained in:
@@ -125,6 +125,28 @@ describe("bluebubblesMessageActions", () => {
|
||||
expect(actions).toContain("unsend");
|
||||
});
|
||||
|
||||
it("honors account-scoped action gates during discovery", () => {
|
||||
const cfg: OpenClawConfig = {
|
||||
channels: {
|
||||
bluebubbles: {
|
||||
serverUrl: "http://localhost:1234",
|
||||
password: "test-password",
|
||||
actions: { reactions: false },
|
||||
accounts: {
|
||||
work: {
|
||||
serverUrl: "http://localhost:5678",
|
||||
password: "work-password",
|
||||
actions: { reactions: true },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
expect(describeMessageTool({ cfg, accountId: "default" })?.actions).not.toContain("react");
|
||||
expect(describeMessageTool({ cfg, accountId: "work" })?.actions).toContain("react");
|
||||
});
|
||||
|
||||
it("hides private-api actions when private API is disabled", () => {
|
||||
vi.mocked(getCachedBlueBubblesPrivateApiStatus).mockReturnValueOnce(false);
|
||||
const cfg: OpenClawConfig = {
|
||||
|
||||
@@ -72,12 +72,12 @@ const PRIVATE_API_ACTIONS = new Set<ChannelMessageActionName>([
|
||||
]);
|
||||
|
||||
export const bluebubblesMessageActions: ChannelMessageActionAdapter = {
|
||||
describeMessageTool: ({ cfg, currentChannelId }) => {
|
||||
const account = resolveBlueBubblesAccount({ cfg: cfg });
|
||||
describeMessageTool: ({ cfg, accountId, currentChannelId }) => {
|
||||
const account = resolveBlueBubblesAccount({ cfg, accountId });
|
||||
if (!account.enabled || !account.configured) {
|
||||
return null;
|
||||
}
|
||||
const gate = createActionGate(cfg.channels?.bluebubbles?.actions);
|
||||
const gate = createActionGate(account.config.actions);
|
||||
const actions = new Set<ChannelMessageActionName>();
|
||||
const macOS26 = isMacOS26OrHigher(account.accountId);
|
||||
const privateApiStatus = getCachedBlueBubblesPrivateApiStatus(account.accountId);
|
||||
|
||||
@@ -31,9 +31,20 @@ export function resolveBlueBubblesAccountFromConfig(params: {
|
||||
cfg?: { channels?: { bluebubbles?: Record<string, unknown> } };
|
||||
accountId?: string;
|
||||
}) {
|
||||
const config = params.cfg?.channels?.bluebubbles ?? {};
|
||||
const baseConfig = params.cfg?.channels?.bluebubbles ?? {};
|
||||
const accountId = params.accountId ?? "default";
|
||||
const accountConfig =
|
||||
accountId === "default"
|
||||
? {}
|
||||
: ((baseConfig.accounts as Record<string, Record<string, unknown> | undefined> | undefined)?.[
|
||||
accountId
|
||||
] ?? {});
|
||||
const config = {
|
||||
...baseConfig,
|
||||
...accountConfig,
|
||||
};
|
||||
return {
|
||||
accountId: params.accountId ?? "default",
|
||||
accountId,
|
||||
enabled: config.enabled !== false,
|
||||
configured: Boolean(config.serverUrl && config.password),
|
||||
config,
|
||||
|
||||
Reference in New Issue
Block a user