From 3ecf288daf913f112fae5c1beef073997bed0760 Mon Sep 17 00:00:00 2001 From: Davidson Gomes Date: Mon, 8 Sep 2025 14:45:29 -0300 Subject: [PATCH] Revert "Ignore events that are not messages (like EPHEMERAL_SYNC_RESPONSE)" --- .../chatwoot/services/chatwoot.service.ts | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts b/src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts index badaba13..c53a9ea4 100644 --- a/src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts +++ b/src/api/integrations/chatbot/chatwoot/services/chatwoot.service.ts @@ -567,13 +567,6 @@ export class ChatwootService { } public async createConversation(instance: InstanceDto, body: any) { - if (!body?.key) { - this.logger.warn( - `body.key is null or undefined in createConversation. Full body object: ${JSON.stringify(body)}`, - ); - return null; - } - const isLid = body.key.previousRemoteJid?.includes('@lid') && body.key.senderPn; const remoteJid = body.key.remoteJid; const cacheKey = `${instance.instanceName}:createConversation-${remoteJid}`; @@ -1900,12 +1893,6 @@ export class ChatwootService { public async eventWhatsapp(event: string, instance: InstanceDto, body: any) { try { - // Ignore events that are not messages (like 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) { @@ -1951,11 +1938,6 @@ export class ChatwootService { } if (event === 'messages.upsert' || event === 'send.message') { - if (!body?.key) { - this.logger.warn(`body.key is null or undefined. Full body object: ${JSON.stringify(body)}`); - return; - } - if (body.key.remoteJid === 'status@broadcast') { return; } @@ -2278,23 +2260,10 @@ export class ChatwootService { } if (event === 'messages.edit' || event === 'send.message.update') { - // Ignore events that are not messages (like 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; - } - const editedText = `${ body?.editedMessage?.conversation || body?.editedMessage?.extendedTextMessage?.text }\n\n_\`${i18next.t('cw.message.edited')}.\`_`; - const message = await this.getMessageByKeyId(instance, body.key.id); + const message = await this.getMessageByKeyId(instance, body?.key?.id); const key = message.key as { id: string; fromMe: boolean;