From 02f931e0555f9c1e28ee8eef996730c1c465a4cc Mon Sep 17 00:00:00 2001 From: borja Date: Fri, 5 Sep 2025 11:06:36 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20A=C3=B1adir=20normalizaci=C3=B3n=20del?= =?UTF-8?q?=20ID=20del=20remitente?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: aider (openrouter/x-ai/grok-code-fast-1) --- src/server.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/server.ts b/src/server.ts index fdfb429..706ac6e 100644 --- a/src/server.ts +++ b/src/server.ts @@ -3,6 +3,7 @@ import { CommandService } from './services/command'; import { GroupSyncService } from './services/group-sync'; import { ResponseQueue } from './services/response-queue'; import { WebhookManager } from './services/webhook-manager'; +import { normalizeWhatsAppId } from './utils/whatsapp'; // Bun is available globally when running under Bun runtime declare global { @@ -107,6 +108,15 @@ export class WebhookServer { return; } + // Normalize sender ID for consistency and validation + const normalizedSenderId = normalizeWhatsAppId(data.key.participant); + if (!normalizedSenderId) { + if (process.env.NODE_ENV !== 'test') { + console.log('⚠️ Invalid sender ID, ignoring message'); + } + return; + } + // Forward to command service only if: // 1. It's a text message (has conversation field) // 2. Starts with /tarea command