Merge pull request #348 from w3nder/master

Fix bug SendWhatsAppMedia mustache body null
This commit is contained in:
Cassio Santos
2022-02-01 12:06:24 -03:00
committed by GitHub

View File

@@ -19,13 +19,16 @@ const SendWhatsAppMedia = async ({
}: Request): Promise<WbotMessage> => { }: Request): Promise<WbotMessage> => {
try { try {
const wbot = await GetTicketWbot(ticket); const wbot = await GetTicketWbot(ticket);
const hasBody = body
? formatBody(body as string, ticket.contact)
: undefined;
const newMedia = MessageMedia.fromFilePath(media.path); const newMedia = MessageMedia.fromFilePath(media.path);
const sentMessage = await wbot.sendMessage( const sentMessage = await wbot.sendMessage(
`${ticket.contact.number}@${ticket.isGroup ? "g" : "c"}.us`, `${ticket.contact.number}@${ticket.isGroup ? "g" : "c"}.us`,
newMedia, newMedia,
{ {
caption: formatBody(body as string, ticket.contact), caption: hasBody,
sendAudioAsVoice: true sendAudioAsVoice: true
} }
); );
@@ -36,6 +39,7 @@ const SendWhatsAppMedia = async ({
return sentMessage; return sentMessage;
} catch (err) { } catch (err) {
console.log(err);
throw new AppError("ERR_SENDING_WAPP_MSG"); throw new AppError("ERR_SENDING_WAPP_MSG");
} }
}; };