-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
Description
Body:
Summary
When sending documents (PDFs, etc.) via the WhatsApp channel, the file always appears as "file" in the recipient's chat regardless of the actual filename. This is because fileName: "file" is hardcoded in the Baileys sendMessage handler's document payload.
Root Cause
Two problems in src/web/outbound.ts → sendMessageWhatsApp() :
1. loadWebMedia() correctly resolves media.fileName (via path.basename(mediaUrl) ), but the fileName is never passed through to active.sendMessage() — it only passes (to, text, mediaBuffer, mediaType) .
2. In the sendMessage handler (where the Baileys payload is built), the document case hardcodes:
js
} else payload = {
document: mediaBuffer,
fileName: "file", // ← always "file"
caption: text || void 0,
mimetype: mediaType
};
Fix
1. Capture media.fileName in sendMessageWhatsApp and pass it through via sendOptions
2. Use sendOptions?.fileName || "file" in the document payload instead of hardcoded "file"
Affected code paths
The hardcoded fileName: "file" appears in the sendMessage handler which is bundled into 4 dist files:
• pi-embedded-.js
• reply-.js
• extensionAPI.js
• loader-*.js
Note
Inbound filename handling was already fixed (per CHANGELOG: "preserve original filenames for inbound documents"), but the outbound side was missed.