|
|
|
@ -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
|
|
|
|
|