mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 09:28:37 +00:00
fix(extensions): synthesize mediaLocalRoots propagation across sendMedia adapters
Restore deterministic mediaLocalRoots propagation through extension sendMedia adapters and add coverage for local/remote media handling in Google Chat. Synthesis of #33581, #33545, #33540, #33536, #33528. Co-authored-by: bmendonca3 <bmendonca3@users.noreply.github.com>
This commit is contained in:
41
extensions/whatsapp/src/channel.test.ts
Normal file
41
extensions/whatsapp/src/channel.test.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { whatsappPlugin } from "./channel.js";
|
||||
|
||||
describe("whatsappPlugin outbound sendMedia", () => {
|
||||
it("forwards mediaLocalRoots to sendMessageWhatsApp", async () => {
|
||||
const sendWhatsApp = vi.fn(async () => ({
|
||||
messageId: "msg-1",
|
||||
toJid: "15551234567@s.whatsapp.net",
|
||||
}));
|
||||
const mediaLocalRoots = ["/tmp/workspace"];
|
||||
|
||||
const outbound = whatsappPlugin.outbound;
|
||||
if (!outbound?.sendMedia) {
|
||||
throw new Error("whatsapp outbound sendMedia is unavailable");
|
||||
}
|
||||
|
||||
const result = await outbound.sendMedia({
|
||||
cfg: {} as never,
|
||||
to: "whatsapp:+15551234567",
|
||||
text: "photo",
|
||||
mediaUrl: "/tmp/workspace/photo.png",
|
||||
mediaLocalRoots,
|
||||
accountId: "default",
|
||||
deps: { sendWhatsApp },
|
||||
gifPlayback: false,
|
||||
});
|
||||
|
||||
expect(sendWhatsApp).toHaveBeenCalledWith(
|
||||
"whatsapp:+15551234567",
|
||||
"photo",
|
||||
expect.objectContaining({
|
||||
verbose: false,
|
||||
mediaUrl: "/tmp/workspace/photo.png",
|
||||
mediaLocalRoots,
|
||||
accountId: "default",
|
||||
gifPlayback: false,
|
||||
}),
|
||||
);
|
||||
expect(result).toMatchObject({ channel: "whatsapp", messageId: "msg-1" });
|
||||
});
|
||||
});
|
||||
@@ -295,11 +295,12 @@ export const whatsappPlugin: ChannelPlugin<ResolvedWhatsAppAccount> = {
|
||||
});
|
||||
return { channel: "whatsapp", ...result };
|
||||
},
|
||||
sendMedia: async ({ to, text, mediaUrl, accountId, deps, gifPlayback }) => {
|
||||
sendMedia: async ({ to, text, mediaUrl, mediaLocalRoots, accountId, deps, gifPlayback }) => {
|
||||
const send = deps?.sendWhatsApp ?? getWhatsAppRuntime().channel.whatsapp.sendMessageWhatsApp;
|
||||
const result = await send(to, text, {
|
||||
verbose: false,
|
||||
mediaUrl,
|
||||
mediaLocalRoots,
|
||||
accountId: accountId ?? undefined,
|
||||
gifPlayback,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user