mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-24 07:01:49 +00:00
fix(regression): preserve bluebubbles pairing account context
This commit is contained in:
56
extensions/bluebubbles/src/channel.pairing.test.ts
Normal file
56
extensions/bluebubbles/src/channel.pairing.test.ts
Normal 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",
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -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,
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user