fix(regression): preserve bluebubbles pairing account context

This commit is contained in:
Tak Hoffman
2026-03-27 23:17:39 -05:00
parent c7e05f1f87
commit f811ce5052
2 changed files with 58 additions and 1 deletions

View File

@@ -0,0 +1,56 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { OpenClawConfig } from "./runtime-api.js";
const sendMessageBlueBubblesMock = vi.hoisted(() => vi.fn());
vi.mock("./channel.runtime.js", () => ({
blueBubblesChannelRuntime: {
sendMessageBlueBubbles: sendMessageBlueBubblesMock,
},
}));
vi.mock("../../../src/channels/plugins/bundled.js", () => ({
bundledChannelPlugins: [],
bundledChannelSetupPlugins: [],
}));
let bluebubblesPlugin: typeof import("./channel.js").bluebubblesPlugin;
describe("bluebubblesPlugin.pairing.notifyApproval", () => {
beforeEach(async () => {
vi.resetModules();
sendMessageBlueBubblesMock.mockReset();
sendMessageBlueBubblesMock.mockResolvedValue({ messageId: "bb-pairing" });
({ bluebubblesPlugin } = await import("./channel.js"));
});
it("preserves accountId when sending pairing approvals", async () => {
const cfg = {
channels: {
bluebubbles: {
accounts: {
work: {
serverUrl: "http://localhost:1234",
password: "test-password",
},
},
},
},
} as OpenClawConfig;
await bluebubblesPlugin.pairing?.notifyApproval?.({
cfg,
id: "+15551234567",
accountId: "work",
});
expect(sendMessageBlueBubblesMock).toHaveBeenCalledWith(
"+15551234567",
expect.any(String),
expect.objectContaining({
cfg,
accountId: "work",
}),
);
});
});

View File

@@ -289,11 +289,12 @@ export const bluebubblesPlugin: ChannelPlugin<ResolvedBlueBubblesAccount, BlueBu
/^bluebubbles:/i,
normalizeBlueBubblesHandle,
),
notify: async ({ cfg, id, message }) => {
notify: async ({ cfg, id, message, accountId }) => {
await (
await loadBlueBubblesChannelRuntime()
).sendMessageBlueBubbles(id, message, {
cfg: cfg,
accountId,
});
},
},