fix(baileys): allow sending captions with document messages#363
Conversation
The baileys adapter was ignoring the `caption` field when sending document messages. This commit passes the `caption` from the media payload to the `sendContent` method. Additionally, it updates `message.service.ts` to correctly store the document's caption in the database instead of defaulting to the filename.
rmyndharis
left a comment
There was a problem hiding this comment.
Nice catch and a clean fix, @Fernixp — approving.
I verified the gap: the whatsapp-web.js adapter already forwards the caption for documents (sendMediaMessage → client.sendMessage(..., { caption: media.caption })), so the Baileys sendDocumentMessage was the only path dropping it. This brings the two engines to parity.
The message.service change (body: dto.caption || dto.filename || '') is a good engine-neutral improvement too: both engines now store the document's caption as the message body, falling back to the filename when there's no caption — and it's backward-compatible (the no-caption case is unchanged). The added spec assertion locks it in.
CI is green (Lint/Test/Build/Dashboard) and the change is minimal and well-scoped. 👍 Thanks for including the test.
|
Thanks for the clean, well-scoped fix, @Fernixp — and for including a regression test. I traced it through end to end and everything lines up:
CI is green across Lint/Test/Build/Dashboard and the change is minimal. This is ready to merge — I'll fold a short CHANGELOG note in on my end so it shows up in the next release. Appreciate the contribution! |
The baileys adapter was ignoring the
captionfield when sending document messages. This commit passes thecaptionfrom the media payload to the
sendContentmethod. Additionally, it updatesmessage.service.tsto correctly store the document's caption in the database instead of defaulting to the filename.Description
This PR fixes an issue where the
captionfield was being completely ignored when sending document payloads (like PDFs) using the Baileys adapter.baileys.adapter.tsto properly pass thecaptionproperty to the underlyingsendContentmethod.message.service.tsso the database stores thecaptionas the messagebodyfor documents, falling back to the filename if a caption isn't provided.baileys.adapter.spec.tsto prevent future regressions.Type of Change
Checklist
Screenshots (if applicable)
N/A
Related Issues
Closes #