fix: guard mediaType fallback, add missing MIME + send-api tests, changelog

This commit is contained in:
Marcus Castro
2026-04-01 23:54:05 -03:00
parent a1eae4d7ac
commit 83f2eabd49
4 changed files with 25 additions and 1 deletions

View File

@@ -1030,6 +1030,7 @@ Docs: https://docs.openclaw.ai
- Exec: harden host env override handling across gateway and node (#51207) Thanks @gladiator9797 and @joshavant.
- Voice Call: enforce spoken-output contract and fix stream TTS silence regression (#51500) Thanks @joshavant.
- xAI/models: rename the bundled Grok 4.20 catalog entries to the GA IDs and normalize saved deprecated beta IDs at runtime so existing configs and sessions keep resolving. (#50772) thanks @Jaaneek
- WhatsApp/outbound media: fix HTML, XML, and CSS files being silently dropped on outbound send by adding missing MIME entries and falling back to `application/octet-stream` for unknown media types. (#51562) Thanks @bobbyt74
- Agents/bootstrap warnings: move bootstrap truncation warnings out of the system prompt and into the per-turn prompt body so prompt-cache reuse stays stable when truncation warnings appear or disappear. (#48753) Thanks @scoootscooob and @obviyus.
- Telegram/DM topic session keys: route named-account DM topics through the same per-account base session key across inbound messages, native commands, and session-state lookups so `/status` and thread recovery stop creating phantom `agent:main:main:thread:...` sessions. (#48204) Thanks @vincentkoc.
- ACP/configured bindings: reinitialize configured ACP sessions that are stuck in `error` state instead of reusing the failed runtime.

View File

@@ -162,4 +162,24 @@ describe("createWebSendApi", () => {
await api.sendComposingTo("+1555");
expect(sendPresenceUpdate).toHaveBeenCalledWith("composing", "1555@s.whatsapp.net");
});
it("sends media as document when mediaType is undefined", async () => {
const mediaBuffer = Buffer.from("test");
await api.sendMessage("123", "hello", mediaBuffer, undefined);
expect(sendMessage).toHaveBeenCalledWith(
"123@s.whatsapp.net",
expect.objectContaining({
document: mediaBuffer,
mimetype: "application/octet-stream",
}),
);
});
it("does not set mediaType when mediaBuffer is absent", async () => {
await api.sendMessage("123", "hello");
expect(sendMessage).toHaveBeenCalledWith("123@s.whatsapp.net", { text: "hello" });
});
});

View File

@@ -34,7 +34,9 @@ export function createWebSendApi(params: {
): Promise<{ messageId: string }> => {
const jid = toWhatsappJid(to);
let payload: AnyMessageContent;
mediaType ??= "application/octet-stream";
if (mediaBuffer) {
mediaType ??= "application/octet-stream";
}
if (mediaBuffer && mediaType) {
if (mediaType.startsWith("image/")) {
payload = {

View File

@@ -138,6 +138,7 @@ describe("extensionForMime", () => {
{ mime: "text/html", expected: ".html" },
{ mime: "text/xml", expected: ".xml" },
{ mime: "text/css", expected: ".css" },
{ mime: "application/xml", expected: ".xml" },
{ mime: "IMAGE/JPEG", expected: ".jpg" },
{ mime: "Audio/X-M4A", expected: ".m4a" },
{ mime: "Video/QuickTime", expected: ".mov" },