Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/engine/adapters/baileys.adapter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -852,12 +852,14 @@ describe('BaileysAdapter media sends', () => {
mimetype: 'application/pdf',
data: Buffer.from('PDFDATA').toString('base64'),
filename: 'doc.pdf',
caption: 'a document',
});
expect(loadRemoteMediaBuffer).not.toHaveBeenCalled();
expect(fakeSock.sendMessage).toHaveBeenCalledWith('628111@s.whatsapp.net', {
document: Buffer.from('PDFDATA'),
mimetype: 'application/pdf',
fileName: 'doc.pdf',
caption: 'a document',
});
});

Expand Down
7 changes: 6 additions & 1 deletion src/engine/adapters/baileys.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,12 @@ export class BaileysAdapter implements IWhatsAppEngine {
async sendDocumentMessage(chatId: string, media: MediaInput): Promise<MessageResult> {
this.ensureReady();
const { data, mimetype } = await this.resolveMediaBuffer(media);
return this.sendContent(chatId, { document: data, mimetype, fileName: media.filename ?? 'file' });
return this.sendContent(chatId, {
document: data,
mimetype,
fileName: media.filename ?? 'file',
caption: media.caption,
});
}

async sendStickerMessage(chatId: string, media: MediaInput): Promise<MessageResult> {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/message/message.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export class MessageService {
// Save message as pending BEFORE sending
const message = await this.saveOutgoingMessage(sessionId, {
chatId: dto.chatId,
body: dto.filename || '',
body: dto.caption || dto.filename || '',
type: 'document',
metadata: {
media: { mimetype: dto.mimetype, filename: dto.filename, data: dto.base64 || dto.url },
Expand Down
Loading