Skip to content

Commit

Permalink
Merge pull request #216 from craines/main
Browse files Browse the repository at this point in the history
fix: Removed await from webhook when sending a message
  • Loading branch information
DavidsonGomes authored Nov 18, 2023
2 parents b0a0e80 + 04e5443 commit e75ef21
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/whatsapp/services/whatsapp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2172,6 +2172,21 @@ export class WAStartupService {
!message['conversation'] &&
sender !== 'status@broadcast'
) {

if (message['reactionMessage']) {
this.logger.verbose('Sending reaction');
return await this.client.sendMessage(
sender,
{
react: {
text: message['reactionMessage']['text'],
key: message['reactionMessage']['key']
}
} as unknown as AnyMessageContent,
option as unknown as MiscMessageGenerationOptions,
);
}

if (!message['audio']) {
this.logger.verbose('Sending message');
return await this.client.sendMessage(
Expand All @@ -2187,7 +2202,6 @@ export class WAStartupService {
);
}
}

if (message['conversation']) {
this.logger.verbose('Sending message');
return await this.client.sendMessage(
Expand Down Expand Up @@ -2235,7 +2249,7 @@ export class WAStartupService {
this.logger.log(messageRaw);

this.logger.verbose('Sending data to webhook in event SEND_MESSAGE');
await this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw);
this.sendDataWebhook(Events.SEND_MESSAGE, messageRaw);

if (this.localChatwoot.enabled && !isChatwoot) {
this.chatwootService.eventWhatsapp(Events.SEND_MESSAGE, { instanceName: this.instance.name }, messageRaw);
Expand Down

0 comments on commit e75ef21

Please sign in to comment.