From 6b72550286b4eb45ce2fefa0bee38b3aef100c37 Mon Sep 17 00:00:00 2001 From: Rafael Nicolas Barbosa Moreira Date: Fri, 3 Jan 2025 15:56:39 -0300 Subject: [PATCH 1/3] fix: include filename in media message payload for WhatsApp Business --- src/api/integrations/channel/meta/whatsapp.business.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/api/integrations/channel/meta/whatsapp.business.service.ts b/src/api/integrations/channel/meta/whatsapp.business.service.ts index 921d0e6d4..bf79c6648 100644 --- a/src/api/integrations/channel/meta/whatsapp.business.service.ts +++ b/src/api/integrations/channel/meta/whatsapp.business.service.ts @@ -807,6 +807,7 @@ export class BusinessStartupService extends ChannelStartupService { [message['mediaType']]: { [message['type']]: message['id'], preview_url: linkPreview, + filename: message['fileName'], caption: message['caption'], }, }; From 08ceb803c8f47b7d8425fd7160380379ce401553 Mon Sep 17 00:00:00 2001 From: Rafael Nicolas Barbosa Moreira Date: Fri, 3 Jan 2025 16:33:34 -0300 Subject: [PATCH 2/3] fix: conditionally include filename for non-image media --- .../integrations/channel/meta/whatsapp.business.service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api/integrations/channel/meta/whatsapp.business.service.ts b/src/api/integrations/channel/meta/whatsapp.business.service.ts index bf79c6648..de8db863a 100644 --- a/src/api/integrations/channel/meta/whatsapp.business.service.ts +++ b/src/api/integrations/channel/meta/whatsapp.business.service.ts @@ -799,6 +799,8 @@ export class BusinessStartupService extends ChannelStartupService { return await this.post(content, 'messages'); } if (message['media']) { + const isImage = message['mimetype']?.startsWith('image/'); + content = { messaging_product: 'whatsapp', recipient_type: 'individual', @@ -807,13 +809,13 @@ export class BusinessStartupService extends ChannelStartupService { [message['mediaType']]: { [message['type']]: message['id'], preview_url: linkPreview, - filename: message['fileName'], + ...(message['fileName'] && !isImage && { filename: message['fileName'] }), // Adiciona filename apenas se não for imagem caption: message['caption'], }, }; quoted ? (content.context = { message_id: quoted.id }) : content; return await this.post(content, 'messages'); - } + } if (message['audio']) { content = { messaging_product: 'whatsapp', From e0c960cc5413a42cad9890ebe80f84740254a4f7 Mon Sep 17 00:00:00 2001 From: Rafael Nicolas Barbosa Moreira Date: Fri, 3 Jan 2025 16:35:14 -0300 Subject: [PATCH 3/3] chore: remove redundant comment about filename condition --- src/api/integrations/channel/meta/whatsapp.business.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/integrations/channel/meta/whatsapp.business.service.ts b/src/api/integrations/channel/meta/whatsapp.business.service.ts index de8db863a..e22fb1ce3 100644 --- a/src/api/integrations/channel/meta/whatsapp.business.service.ts +++ b/src/api/integrations/channel/meta/whatsapp.business.service.ts @@ -809,7 +809,7 @@ export class BusinessStartupService extends ChannelStartupService { [message['mediaType']]: { [message['type']]: message['id'], preview_url: linkPreview, - ...(message['fileName'] && !isImage && { filename: message['fileName'] }), // Adiciona filename apenas se não for imagem + ...(message['fileName'] && !isImage && { filename: message['fileName'] }), caption: message['caption'], }, };