feat: Añadir normalización del ID del remitente

Co-authored-by: aider (openrouter/x-ai/grok-code-fast-1) <aider@aider.chat>
pull/1/head
borja 2 months ago
parent 4e96c71910
commit 02f931e055

@ -3,6 +3,7 @@ import { CommandService } from './services/command';
import { GroupSyncService } from './services/group-sync'; import { GroupSyncService } from './services/group-sync';
import { ResponseQueue } from './services/response-queue'; import { ResponseQueue } from './services/response-queue';
import { WebhookManager } from './services/webhook-manager'; import { WebhookManager } from './services/webhook-manager';
import { normalizeWhatsAppId } from './utils/whatsapp';
// Bun is available globally when running under Bun runtime // Bun is available globally when running under Bun runtime
declare global { declare global {
@ -107,6 +108,15 @@ export class WebhookServer {
return; 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: // Forward to command service only if:
// 1. It's a text message (has conversation field) // 1. It's a text message (has conversation field)
// 2. Starts with /tarea command // 2. Starts with /tarea command

Loading…
Cancel
Save