From 5211d83e8bcb16643d25952efa5b1a39fe2a06d4 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Fri, 13 Mar 2026 15:26:14 -0500 Subject: [PATCH] fix: eliminar polling get_notifications en index.php + debug wamid en broadcast MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - index.php: NotificationManager simplificado a stub vacío. Los elementos notification-bell / global-notification-toasts no existen en el markup → el setInterval cada 7s solo generaba tráfico inútil a get_notifications.php Las notificaciones ya se manejan vía SSE en conversations.php - send_broadcast.php: exponer debug_wamids en respuesta (wamid, wa_status, wa_contact) para saber exactamente qué devuelve WhatsApp por cada destinatario. Agregar dryRun log del payload completo al error_log para diagnóstico de mensajes que WhatsApp acepta (200+wamid) pero no entrega. --- api/send_broadcast.php | 23 ++++- index.php | 197 +---------------------------------------- 2 files changed, 25 insertions(+), 195 deletions(-) diff --git a/api/send_broadcast.php b/api/send_broadcast.php index d70de50..fb38e63 100644 --- a/api/send_broadcast.php +++ b/api/send_broadcast.php @@ -90,6 +90,7 @@ try { $sentCount = 0; $errorCount = 0; $errors = []; + $debugWamids = []; foreach ($users as $user) { try { @@ -185,6 +186,19 @@ try { $processedVariables, $headerParams ); + + // Log payload para diagnóstico + $dryPayload = $whatsappService->sendTemplateMessage( + $user['phone_number'], + $template['template_name'] ?? $template['name'], + $template['language_code'] ?? 'es', + $processedVariables, + $headerParams, + null, null, true // dryRun=true + ); + error_log("=== BROADCAST TEMPLATE PAYLOAD (para " . $user['phone_number'] . ") ==="); + error_log(json_encode($dryPayload, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)); + error_log("=== FIN PAYLOAD ==="); // Construir contenido para BD (reemplazar variables en body_text) $messageContent = $template['body_text'] ?? $template['name']; @@ -218,6 +232,12 @@ try { if ($isSuccess) { $sentCount++; + $debugWamids[] = [ + 'phone' => $user['phone_number'], + 'wamid' => $sentMessageId, + 'wa_status' => $response['messages'][0]['message_status'] ?? 'accepted', + 'wa_contact' => $response['contacts'][0]['wa_id'] ?? null, + ]; // Guardar mensaje en BD $db->insert('conversations', [ @@ -258,7 +278,8 @@ try { 'total_users' => count($users), 'selection_type' => $selectionType, 'message_type' => $messageType, - 'errors' => $errorCount > 0 ? $errors : null + 'errors' => $errorCount > 0 ? $errors : null, + 'debug_wamids' => $debugWamids ?? [] ]); } catch (Exception $e) { diff --git a/index.php b/index.php index 935bf9d..c44f67d 100644 --- a/index.php +++ b/index.php @@ -1576,200 +1576,9 @@ try {