fix: eliminar polling get_notifications en index.php + debug wamid en broadcast
- 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.
This commit is contained in:
+22
-1
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user