From fd1f08a41ebf48abdec7f65f59c3201768600ee2 Mon Sep 17 00:00:00 2001 From: Felipe Medeiros Date: Tue, 5 Nov 2024 17:16:41 -0300 Subject: [PATCH] feat: handle quoted messages in WhatsApp integration --- .../channel/whatsapp/whatsapp.baileys.service.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts index 0afd5318a..a01559e37 100644 --- a/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts +++ b/src/api/integrations/channel/whatsapp/whatsapp.baileys.service.ts @@ -4259,6 +4259,19 @@ export class BaileysStartupService extends ChannelStartupService { delete messageRaw.message.documentWithCaptionMessage; } + const quotedMessage = messageRaw?.contextInfo?.quotedMessage; + if (quotedMessage) { + if (quotedMessage.extendedTextMessage) { + quotedMessage.conversation = quotedMessage.extendedTextMessage.text; + delete quotedMessage.extendedTextMessage; + } + + if (quotedMessage.documentWithCaptionMessage) { + quotedMessage.documentMessage = quotedMessage.documentWithCaptionMessage.message.documentMessage; + delete quotedMessage.documentWithCaptionMessage; + } + } + return messageRaw; }