fix: stop repeated/duplicate bot responses

Root cause: WpWebhook called OutboundWorker::processQueue() after every
incoming message. BotRouter already sends synchronously in enqueueResponse();
failed messages stayed status='queued'. On the next incoming message
processQueue() would re-send ALL previously-failed messages, causing
the bot to repeat old responses.

- Remove OutboundWorker::processQueue() from WpWebhook::processEvent()
  BotRouter handles immediate delivery; retries should be manual/cron only
- Fix chatSend(): instead of queuing + processQueue() (which drains ALL
  queued messages), call WhatsAppSender::sendText() directly for the
  one message being sent

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-06-29 09:05:24 -05:00
co-authored by Claude Sonnet 4.6
parent cb348bd602
commit e3be2d5b3f
2 changed files with 19 additions and 15 deletions
+3 -7
View File
@@ -144,13 +144,9 @@ class WpWebhook
// Persistir evento crudo para auditoría
self::saveRawEvent($raw);
// Procesar cola outbound inmediatamente para respuestas automáticas
try {
OutboundWorker::processQueue();
} catch (\Throwable $e) {
self::log('WARN', 'OutboundWorker falló: ' . $e->getMessage());
}
// Note: BotRouter already sends synchronously in enqueueResponse().
// Running processQueue() here would re-send ALL previously-failed messages
// on every incoming webhook, causing duplicate/repeated responses.
}
private static function resolveCompany(array $payload): void