From a1eae4d7ac1a1d5ae8f316aa40623ebe9646972c Mon Sep 17 00:00:00 2001 From: Yosi Taguri Date: Sat, 21 Mar 2026 12:24:09 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20address=20review=20=E2=80=94=20pin=20.xm?= =?UTF-8?q?l=20alias=20in=20MIME=5FBY=5FEXT,=20hoist=20fallback=20above=20?= =?UTF-8?q?condition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Pin '.xml': 'text/xml' in MIME_BY_EXT overrides to prevent application/xml from overwriting text/xml in the reversed map - Move mediaType ??= fallback above the if-guard in send-api.ts for clarity (avoids side-effect assignment inside condition) --- extensions/whatsapp/src/inbound/send-api.ts | 3 ++- src/media/mime.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/extensions/whatsapp/src/inbound/send-api.ts b/extensions/whatsapp/src/inbound/send-api.ts index 73a674c2362..7b7145a5e28 100644 --- a/extensions/whatsapp/src/inbound/send-api.ts +++ b/extensions/whatsapp/src/inbound/send-api.ts @@ -34,7 +34,8 @@ export function createWebSendApi(params: { ): Promise<{ messageId: string }> => { const jid = toWhatsappJid(to); let payload: AnyMessageContent; - if (mediaBuffer && (mediaType ??= "application/octet-stream")) { + mediaType ??= "application/octet-stream"; + if (mediaBuffer && mediaType) { if (mediaType.startsWith("image/")) { payload = { image: mediaBuffer, diff --git a/src/media/mime.ts b/src/media/mime.ts index 5f0be864440..33e52eddbdd 100644 --- a/src/media/mime.ts +++ b/src/media/mime.ts @@ -48,6 +48,7 @@ const MIME_BY_EXT: Record = { ".jpeg": "image/jpeg", ".js": "text/javascript", ".htm": "text/html", + ".xml": "text/xml", // pin text/xml as canonical (application/xml also maps to .xml in EXT_BY_MIME) }; const AUDIO_FILE_EXTENSIONS = new Set([