From 31dbc8aa862c5b2f406763e38ab7e5de20bc91ce Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Wed, 21 Jan 2026 22:11:12 -0500 Subject: [PATCH] up --- api/get_conversation_detail.php | 17 ++++++++-- api/version/media-url_debug.log | 18 +++++++++++ api/version/media-url_error.log | 8 +++++ chat_window.php | 52 +++++++++++++++++++++++++++++++ classes/Database.php | 2 +- logs/system.log | 19 +++++++++++ scripts/test_in_service_block.php | 21 +++++++++++++ services/BotService.php | 20 ++++++++++++ services/WhatsAppService.php | 5 ++- 9 files changed, 158 insertions(+), 4 deletions(-) create mode 100644 scripts/test_in_service_block.php diff --git a/api/get_conversation_detail.php b/api/get_conversation_detail.php index 6d64a35..e0e1c80 100644 --- a/api/get_conversation_detail.php +++ b/api/get_conversation_detail.php @@ -30,7 +30,7 @@ try { // Obtener información del usuario $user = $db->fetch( - "SELECT id, phone_number, name FROM users WHERE id = ?", + "SELECT id, phone_number, name, in_service, in_service_by, in_service_at FROM users WHERE id = ?", [$user_id] ); @@ -39,6 +39,15 @@ try { echo json_encode(['error' => 'Usuario no encontrado']); exit; } + + // Si la conversación está siendo atendida, resolver el nombre del operador + $inServiceByName = null; + if (!empty($user['in_service_by'])) { + $admin = $db->fetch("SELECT id, full_name, username FROM admin_users WHERE id = ?", [$user['in_service_by']]); + if ($admin) { + $inServiceByName = $admin['full_name'] ?: $admin['username']; + } + } // Obtener todos los mensajes de la conversación $conversations = $db->fetchAll( @@ -122,7 +131,11 @@ try { 'user' => [ 'id' => intval($user['id']), 'phone_number' => $user['phone_number'], - 'name' => $user['name'] ?? $user['phone_number'] + 'name' => $user['name'] ?? $user['phone_number'], + 'in_service' => !empty($user['in_service']) ? true : false, + 'in_service_by' => isset($user['in_service_by']) ? intval($user['in_service_by']) : null, + 'in_service_at' => $user['in_service_at'] ?? null, + 'in_service_by_name' => $inServiceByName ], 'conversations' => $conversations, 'total_conversations' => count($conversations) diff --git a/api/version/media-url_debug.log b/api/version/media-url_debug.log index 9df10b8..c4484b0 100644 --- a/api/version/media-url_debug.log +++ b/api/version/media-url_debug.log @@ -44,3 +44,21 @@ [2026-01-21 14:40:09] Request: GET /api/version/media-url.php?id=3932473397057815 GET:{"id":"3932473397057815"} POST:[] [2026-01-21 14:40:09] Graph API request to https://graph.facebook.com/v22.0/3932473397057815 [2026-01-21 14:40:10] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=3932473397057815&source=getMedia&ext=1769024699&hash=ARlXiE4qXDbAzqzvCutrIryD_tdYaN1gjuIZWoBHDbilqQ +[2026-01-21 21:35:15] Request: GET /api/version/media-url.php?id=3932473397057815 GET:{"id":"3932473397057815"} POST:[] +[2026-01-21 21:35:15] Graph API request to https://graph.facebook.com/v22.0/3932473397057815 +[2026-01-21 21:35:16] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=3932473397057815&source=getMedia&ext=1769049615&hash=ARl0ssx82h2xALShS68EX09cnPLDRp3xDrMkXLHxNpYdmQ +[2026-01-21 21:39:36] Request: GET /api/version/media-url.php?id=3932473397057815 GET:{"id":"3932473397057815"} POST:[] +[2026-01-21 21:39:36] Graph API request to https://graph.facebook.com/v22.0/3932473397057815 +[2026-01-21 21:39:37] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=3932473397057815&source=getMedia&ext=1769049877&hash=ARkt4u_w991l5uoAEPQPa_zaMV4_P5fD4HAa6ClILfS5ZA +[2026-01-21 21:55:37] Request: GET /api/version/media-url.php?id=3932473397057815 GET:{"id":"3932473397057815"} POST:[] +[2026-01-21 21:55:37] Graph API request to https://graph.facebook.com/v22.0/3932473397057815 +[2026-01-21 21:55:37] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=3932473397057815&source=getMedia&ext=1769050837&hash=ARn_VZzaTBKkCf7WJMaJHiVu3cYe_pxGrq1Ix9YvppbNBA +[2026-01-21 21:59:29] Request: GET /api/version/media-url.php?id=3932473397057815 GET:{"id":"3932473397057815"} POST:[] +[2026-01-21 21:59:29] Graph API request to https://graph.facebook.com/v22.0/3932473397057815 +[2026-01-21 21:59:30] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=3932473397057815&source=getMedia&ext=1769051070&hash=ARn9gwkRZ-Tfpv4cSUtMh9pebsJNis-s5tEQeIhxh7iPAA +[2026-01-21 22:00:11] Request: GET /api/version/media-url.php?id=3932473397057815 GET:{"id":"3932473397057815"} POST:[] +[2026-01-21 22:00:11] Graph API request to https://graph.facebook.com/v22.0/3932473397057815 +[2026-01-21 22:00:11] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=3932473397057815&source=getMedia&ext=1769051111&hash=ARnFCx7vV54UV2Z2LJnp3JMsxseZMInCxX8bM-xz0mM5AA +[2026-01-21 22:05:03] Request: GET /api/version/media-url.php?id=3932473397057815 GET:{"id":"3932473397057815"} POST:[] +[2026-01-21 22:05:03] Graph API request to https://graph.facebook.com/v22.0/3932473397057815 +[2026-01-21 22:05:03] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=3932473397057815&source=getMedia&ext=1769051403&hash=ARm7CptuN3CH6WN5V1RmuW6rK9iIipE_KE1-FLbj3RQuHQ diff --git a/api/version/media-url_error.log b/api/version/media-url_error.log index 45b6ec2..6ed5eb5 100644 --- a/api/version/media-url_error.log +++ b/api/version/media-url_error.log @@ -2,3 +2,11 @@ [21-Jan-2026 14:31:30 America/Bogota] PHP Warning: preg_match(): Unknown modifier '&' in C:\laragon\www\whatsapp\api\version\media-url.php on line 131 [21-Jan-2026 14:33:32 America/Bogota] PHP Warning: preg_match(): Unknown modifier '&' in C:\laragon\www\whatsapp\api\version\media-url.php on line 131 [21-Jan-2026 14:35:45 America/Bogota] PHP Warning: preg_match(): Unknown modifier '&' in C:\laragon\www\whatsapp\api\version\media-url.php on line 131 +[21-Jan-2026 21:35:16 America/Bogota] PHP Deprecated: Function curl_close() is deprecated since 8.5, as it has no effect since PHP 8.0 in /Users/lizandro/Documents/GitHub/whatsapp/api/version/media-url.php on line 203 +[21-Jan-2026 21:35:17 America/Bogota] PHP Deprecated: Function curl_close() is deprecated since 8.5, as it has no effect since PHP 8.0 in /Users/lizandro/Documents/GitHub/whatsapp/api/version/media-url.php on line 522 +[21-Jan-2026 21:39:37 America/Bogota] PHP Deprecated: Function curl_close() is deprecated since 8.5, as it has no effect since PHP 8.0 in /Users/lizandro/Documents/GitHub/whatsapp/api/version/media-url.php on line 203 +[21-Jan-2026 21:39:37 America/Bogota] PHP Deprecated: Function curl_close() is deprecated since 8.5, as it has no effect since PHP 8.0 in /Users/lizandro/Documents/GitHub/whatsapp/api/version/media-url.php on line 522 +[21-Jan-2026 21:55:37 America/Bogota] PHP Deprecated: Function curl_close() is deprecated since 8.5, as it has no effect since PHP 8.0 in /Users/lizandro/Documents/GitHub/whatsapp/api/version/media-url.php on line 203 +[21-Jan-2026 21:55:38 America/Bogota] PHP Deprecated: Function curl_close() is deprecated since 8.5, as it has no effect since PHP 8.0 in /Users/lizandro/Documents/GitHub/whatsapp/api/version/media-url.php on line 522 +[21-Jan-2026 21:59:30 America/Bogota] PHP Deprecated: Function curl_close() is deprecated since 8.5, as it has no effect since PHP 8.0 in /Users/lizandro/Documents/GitHub/whatsapp/api/version/media-url.php on line 203 +[21-Jan-2026 21:59:30 America/Bogota] PHP Deprecated: Function curl_close() is deprecated since 8.5, as it has no effect since PHP 8.0 in /Users/lizandro/Documents/GitHub/whatsapp/api/version/media-url.php on line 522 diff --git a/chat_window.php b/chat_window.php index 129aa39..2bc4385 100644 --- a/chat_window.php +++ b/chat_window.php @@ -357,6 +357,10 @@ if (empty($user_id)) {