Skip to content

Commit f11d468

Browse files
committed
ajustes wa business
1 parent aa5ed13 commit f11d468

2 files changed

Lines changed: 31 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Correction when sending files with captions on Whatsapp Business
66
* Correction in receiving messages with response on WhatsApp Business
77
* Correction when sending a reaction to a message on WhatsApp Business
8+
* Correction of receiving reactions on WhatsApp business
89
* Removed mandatory description of rows from sendList
910
* Feature to collect message type in typebot
1011

src/whatsapp/services/whatsapp.business.service.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,20 @@ export class BusinessStartupService extends WAStartupService {
194194
return content;
195195
}
196196

197+
private messageReactionJson(received: any) {
198+
const message = received.messages[0];
199+
let content: any = {
200+
reactionMessage: {
201+
key: {
202+
id: message.reaction.message_id,
203+
},
204+
text: message.reaction.emoji,
205+
},
206+
};
207+
message.context ? (content = { ...content, contextInfo: { stanzaId: message.context.id } }) : content;
208+
return content;
209+
}
210+
197211
private messageTextJson(received: any) {
198212
let content: any;
199213
const message = received.messages[0];
@@ -344,6 +358,18 @@ export class BusinessStartupService extends WAStartupService {
344358
owner: this.instance.name,
345359
// source: getDevice(received.key.id),
346360
};
361+
} else if (received?.messages[0].reaction) {
362+
messageRaw = {
363+
key,
364+
pushName,
365+
message: {
366+
...this.messageReactionJson(received),
367+
},
368+
messageType: 'reactionMessage',
369+
messageTimestamp: received.messages[0].timestamp as number,
370+
owner: this.instance.name,
371+
// source: getDevice(received.key.id),
372+
};
347373
} else if (received?.messages[0].contacts) {
348374
messageRaw = {
349375
key,
@@ -1205,6 +1231,10 @@ export class BusinessStartupService extends WAStartupService {
12051231
}
12061232
}
12071233

1234+
public async deleteMessage() {
1235+
throw new BadRequestException('Method not available on WhatsApp Business API');
1236+
}
1237+
12081238
// methods not available on WhatsApp Business API
12091239
public async mediaSticker() {
12101240
throw new BadRequestException('Method not available on WhatsApp Business API');
@@ -1227,9 +1257,6 @@ export class BusinessStartupService extends WAStartupService {
12271257
public async archiveChat() {
12281258
throw new BadRequestException('Method not available on WhatsApp Business API');
12291259
}
1230-
public async deleteMessage() {
1231-
throw new BadRequestException('Method not available on WhatsApp Business API');
1232-
}
12331260
public async fetchProfile() {
12341261
throw new BadRequestException('Method not available on WhatsApp Business API');
12351262
}

0 commit comments

Comments
 (0)