This commit is contained in:
Lizandro Guarnizo
2026-01-27 00:52:36 -05:00
parent 68374b8127
commit 269dc6bed1
3 changed files with 176 additions and 0 deletions
+12
View File
@@ -304,6 +304,18 @@ class WhatsAppWebhook {
} catch (Exception $e) {
error_log('Failed to create notification: ' . $e->getMessage());
}
// Try to publish a lightweight event to Redis so SSE/WebSocket listeners can be notified immediately
try {
if (extension_loaded('redis')) {
$payload = json_encode(['type' => 'new_message', 'user_id' => $user['id'], 'message_id' => (int)$conversationId, 'created_at' => date('Y-m-d H:i:s')]);
$r = new Redis();
$r->connect('127.0.0.1');
$r->publish('user_' . $user['id'], $payload);
}
} catch (Exception $e) {
error_log('[webhook] redis publish failed: ' . $e->getMessage());
}
// Procesar con bot (protección contra excepciones externas)
try {