From fd6ddc9b6213a791e08b179ae8d6cb5bacc99708 Mon Sep 17 00:00:00 2001 From: Wender Teixeira Date: Wed, 19 Jan 2022 14:30:30 -0300 Subject: [PATCH] Fix bug SendWhatsAppMedia mustache body null --- backend/src/services/WbotServices/SendWhatsAppMedia.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/src/services/WbotServices/SendWhatsAppMedia.ts b/backend/src/services/WbotServices/SendWhatsAppMedia.ts index 9c07421..72760e9 100644 --- a/backend/src/services/WbotServices/SendWhatsAppMedia.ts +++ b/backend/src/services/WbotServices/SendWhatsAppMedia.ts @@ -19,13 +19,16 @@ const SendWhatsAppMedia = async ({ }: Request): Promise => { try { const wbot = await GetTicketWbot(ticket); + const hasBody = body + ? formatBody(body as string, ticket.contact) + : undefined; const newMedia = MessageMedia.fromFilePath(media.path); const sentMessage = await wbot.sendMessage( `${ticket.contact.number}@${ticket.isGroup ? "g" : "c"}.us`, newMedia, { - caption: formatBody(body as string, ticket.contact), + caption: hasBody, sendAudioAsVoice: true } ); @@ -36,6 +39,7 @@ const SendWhatsAppMedia = async ({ return sentMessage; } catch (err) { + console.log(err); throw new AppError("ERR_SENDING_WAPP_MSG"); } };