From 44d4781f6f01f2372c8ac3b2db105e7255901ce8 Mon Sep 17 00:00:00 2001 From: Rafael Souza Date: Thu, 17 Jul 2025 15:37:37 -0300 Subject: [PATCH] Ignore events that are not messages --- .../chatbot/chatwoot/services/chatwoot.service.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts b/src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts index a72e1329..f7ee2249 100644 --- a/src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts +++ b/src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts @@ -1898,6 +1898,12 @@ export class ChatwootService { public async eventWhatsapp(event: string, instance: InstanceDto, body: any) { try { + // Ignora eventos que não são mensagens (como EPHEMERAL_SYNC_RESPONSE) + if (body?.type && body.type !== 'message' && body.type !== 'conversation') { + this.logger.verbose(`Ignoring non-message event type: ${body.type}`); + return; + } + const waInstance = this.waMonitor.waInstances[instance.instanceName]; if (!waInstance) { @@ -2270,6 +2276,12 @@ export class ChatwootService { } if (event === 'messages.edit' || event === 'send.message.update') { + // Ignora eventos que não são mensagens (como EPHEMERAL_SYNC_RESPONSE) + if (body?.type && body.type !== 'message') { + this.logger.verbose(`Ignoring non-message event type: ${body.type}`); + return; + } + if (!body?.key?.id) { this.logger.warn(`body.key.id is null or undefined in messages.edit. Full body object: ${JSON.stringify(body)}`); return;