From f551242e86feb85a0578e1ecdf955f6a7256b682 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Tue, 11 Jun 2024 11:07:49 -0300 Subject: [PATCH] fix: reply message --- .../integrations/chatwoot/services/chatwoot.service.ts | 8 +------- src/api/services/channels/whatsapp.baileys.service.ts | 9 ++++----- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/api/integrations/chatwoot/services/chatwoot.service.ts b/src/api/integrations/chatwoot/services/chatwoot.service.ts index 21647ce8a..fa97ac2e3 100644 --- a/src/api/integrations/chatwoot/services/chatwoot.service.ts +++ b/src/api/integrations/chatwoot/services/chatwoot.service.ts @@ -725,8 +725,6 @@ export class ChatwootService { const sourceReplyId = quotedMsg?.chatwootMessageId || null; - console.log('sourceReplyId', sourceReplyId); - const message = await client.messages.create({ accountId: this.provider.accountId, conversationId: conversationId, @@ -1440,7 +1438,7 @@ export class ChatwootService { }, }); - const key = message.key as { + const key = message?.key as { id: string; fromMe: boolean; remoteJid: string; @@ -1747,8 +1745,6 @@ export class ChatwootService { const quotedId = body.contextInfo?.stanzaId || body.message?.contextInfo?.stanzaId; - console.log('quotedId', quotedId); - let quotedMsg = null; if (quotedId) @@ -1761,8 +1757,6 @@ export class ChatwootService { }, }); - console.log('quotedMsg', quotedMsg); - const isMedia = this.isMediaMessage(body.message); const adsMessage = this.getAdsMessage(body.message); diff --git a/src/api/services/channels/whatsapp.baileys.service.ts b/src/api/services/channels/whatsapp.baileys.service.ts index 689efd04c..7ef544351 100644 --- a/src/api/services/channels/whatsapp.baileys.service.ts +++ b/src/api/services/channels/whatsapp.baileys.service.ts @@ -1124,7 +1124,6 @@ export class BaileysStartupService extends ChannelStartupService { this.localWebhook.webhookBase64 === true || (this.configService.get('TYPEBOT').SEND_MEDIA_BASE64 && isMedia) ) { - console.log('Download media'); const buffer = await downloadMediaMessage( { key: received.key, message: received?.message }, 'buffer', @@ -1173,10 +1172,6 @@ export class BaileysStartupService extends ChannelStartupService { this.sendDataWebhook(Events.MESSAGES_UPSERT, messageRaw); - await this.prismaRepository.message.create({ - data: messageRaw, - }); - if ( this.configService.get('CHATWOOT').ENABLED && this.localChatwoot.enabled && @@ -1195,6 +1190,10 @@ export class BaileysStartupService extends ChannelStartupService { } } + await this.prismaRepository.message.create({ + data: messageRaw, + }); + if (this.configService.get('TYPEBOT').ENABLED) { if (type === 'notify') { if (messageRaw.messageType !== 'reactionMessage')