diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ab6d81b..e66467c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Correction when sending files with captions on Whatsapp Business * Correction in receiving messages with response on WhatsApp Business * Correction when sending a reaction to a message on WhatsApp Business +* Correction of receiving reactions on WhatsApp business * Removed mandatory description of rows from sendList * Feature to collect message type in typebot diff --git a/src/whatsapp/services/whatsapp.business.service.ts b/src/whatsapp/services/whatsapp.business.service.ts index 90f2e04c..2b4a32cf 100644 --- a/src/whatsapp/services/whatsapp.business.service.ts +++ b/src/whatsapp/services/whatsapp.business.service.ts @@ -194,6 +194,20 @@ export class BusinessStartupService extends WAStartupService { return content; } + private messageReactionJson(received: any) { + const message = received.messages[0]; + let content: any = { + reactionMessage: { + key: { + id: message.reaction.message_id, + }, + text: message.reaction.emoji, + }, + }; + message.context ? (content = { ...content, contextInfo: { stanzaId: message.context.id } }) : content; + return content; + } + private messageTextJson(received: any) { let content: any; const message = received.messages[0]; @@ -344,6 +358,18 @@ export class BusinessStartupService extends WAStartupService { owner: this.instance.name, // source: getDevice(received.key.id), }; + } else if (received?.messages[0].reaction) { + messageRaw = { + key, + pushName, + message: { + ...this.messageReactionJson(received), + }, + messageType: 'reactionMessage', + messageTimestamp: received.messages[0].timestamp as number, + owner: this.instance.name, + // source: getDevice(received.key.id), + }; } else if (received?.messages[0].contacts) { messageRaw = { key, @@ -1205,6 +1231,10 @@ export class BusinessStartupService extends WAStartupService { } } + public async deleteMessage() { + throw new BadRequestException('Method not available on WhatsApp Business API'); + } + // methods not available on WhatsApp Business API public async mediaSticker() { throw new BadRequestException('Method not available on WhatsApp Business API'); @@ -1227,9 +1257,6 @@ export class BusinessStartupService extends WAStartupService { public async archiveChat() { throw new BadRequestException('Method not available on WhatsApp Business API'); } - public async deleteMessage() { - throw new BadRequestException('Method not available on WhatsApp Business API'); - } public async fetchProfile() { throw new BadRequestException('Method not available on WhatsApp Business API'); }