Skip to content

Commit

Permalink
ajustes wa business
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidsonGomes committed Apr 3, 2024
1 parent aa5ed13 commit f11d468
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
33 changes: 30 additions & 3 deletions src/whatsapp/services/whatsapp.business.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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');
Expand All @@ -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');
}
Expand Down

0 comments on commit f11d468

Please sign in to comment.