Fix bug SendWhatsAppMedia mustache body null

This commit is contained in:
Wender Teixeira
2022-01-19 14:30:30 -03:00
parent 003dc86d90
commit fd6ddc9b62

View File

@@ -19,13 +19,16 @@ const SendWhatsAppMedia = async ({
}: Request): Promise<WbotMessage> => {
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");
}
};