From 91f009a617a7ab9345d85f3083f603cfacc7ab9c Mon Sep 17 00:00:00 2001 From: raimartinsb Date: Mon, 12 Aug 2024 10:52:56 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20Corre=C3=A7=C3=A3o=20das=20m=C3=ADdias?= =?UTF-8?q?=20como=20anexo=20no=20chatwoot=20quando=20usamos=20uma=20Insta?= =?UTF-8?q?nce=20da=20Meta=20e=20enviando=20nome=20do=20arquivo=20para=20a?= =?UTF-8?q?=20meta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/integrations/chatwoot/services/chatwoot.service.ts | 4 ++-- src/api/services/channels/whatsapp.business.service.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/api/integrations/chatwoot/services/chatwoot.service.ts b/src/api/integrations/chatwoot/services/chatwoot.service.ts index f209a9f3..f8ad2b28 100644 --- a/src/api/integrations/chatwoot/services/chatwoot.service.ts +++ b/src/api/integrations/chatwoot/services/chatwoot.service.ts @@ -741,7 +741,6 @@ export class ChatwootService { findByName = inbox.payload.find((inbox) => inbox.name === this.getClientCwConfig().name_inbox.split('-cwId-')[0]); } - if (!findByName) { this.logger.warn('inbox not found'); return null; @@ -1907,7 +1906,8 @@ export class ChatwootService { let nameFile: string; const messageBody = body?.message[body?.messageType]; - const originalFilename = messageBody?.fileName || messageBody?.message?.documentMessage?.fileName; + const originalFilename = + messageBody?.fileName || messageBody?.filename || messageBody?.message?.documentMessage?.fileName; if (originalFilename) { const parsedFile = path.parse(originalFilename); if (parsedFile.name && parsedFile.ext) { diff --git a/src/api/services/channels/whatsapp.business.service.ts b/src/api/services/channels/whatsapp.business.service.ts index 86178659..0bf73dbc 100644 --- a/src/api/services/channels/whatsapp.business.service.ts +++ b/src/api/services/channels/whatsapp.business.service.ts @@ -743,6 +743,7 @@ export class BusinessStartupService extends ChannelStartupService { [message['type']]: message['id'], preview_url: linkPreview, caption: message['caption'], + filename: message['fileName'], }, }; quoted ? (content.context = { message_id: quoted.id }) : content; @@ -1212,7 +1213,7 @@ export class BusinessStartupService extends ChannelStartupService { try { const msg = data.message; this.logger.verbose('Getting base64 from media message'); - const messageType = msg.messageType + 'Message'; + const messageType = msg.messageType.includes('Message') ? msg.messageType : msg.messageType + 'Message'; const mediaMessage = msg.message[messageType]; this.logger.verbose('Media message downloaded');