From f0a713e1dab2d1abdc2f3431e62ad6aa00014305 Mon Sep 17 00:00:00 2001 From: lizandrogd <77708265+lizandrogd@users.noreply.github.com> Date: Tue, 13 Jan 2026 02:24:18 -0500 Subject: [PATCH] up --- api/get_conversation_detail.php | 6 ++++ api/upload_media.php | 2 +- chat_window.php | 23 +++++++++--- debug_media_messages.php | 64 +++++++++++++++++++++++++++++++++ test_media_api_debug.php | 4 +-- 5 files changed, 92 insertions(+), 7 deletions(-) create mode 100644 debug_media_messages.php diff --git a/api/get_conversation_detail.php b/api/get_conversation_detail.php index b2ce04f..322ebba 100644 --- a/api/get_conversation_detail.php +++ b/api/get_conversation_detail.php @@ -48,10 +48,15 @@ try { direction, message_type, content, + media_url, status, created_at FROM conversations WHERE user_id = ? + AND ( + message_type = 'text' + OR (message_type IN ('image', 'audio', 'video', 'document') AND media_url IS NOT NULL AND media_url != '') + ) ORDER BY created_at ASC", [$user_id] ); @@ -64,6 +69,7 @@ try { 'direction' => $msg['direction'], 'message_type' => $msg['message_type'], 'content' => $msg['content'] ?? '', + 'media_url' => $msg['media_url'] ?? null, 'status' => $msg['status'] ?? 'sent', 'created_at' => $msg['created_at'], 'time' => date('H:i', strtotime($msg['created_at'])), diff --git a/api/upload_media.php b/api/upload_media.php index ac1cd0f..adc81aa 100644 --- a/api/upload_media.php +++ b/api/upload_media.php @@ -86,7 +86,7 @@ try { // Construir URL pública $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http'; $host = $_SERVER['HTTP_HOST']; - $publicUrl = $protocol . '://' . $host . '/whatsapp/uploads/' . $uniqueName; + $publicUrl = $protocol . '://' . $host . '/uploads/' . $uniqueName; // Determinar tipo de medio $mediaType = 'document'; diff --git a/chat_window.php b/chat_window.php index 4b85d14..54305d3 100644 --- a/chat_window.php +++ b/chat_window.php @@ -570,11 +570,24 @@ if (empty($user_id)) { const isOutgoing = msg.direction === 'outgoing'; const messageClass = isOutgoing ? 'message-outgoing' : 'message-incoming'; - // Verificar si es multimedia + // Debug: ver todos los datos del mensaje + console.log('Procesando mensaje:', { + id: msg.id, + type: msg.message_type, + has_media_url: !!msg.media_url, + media_url: msg.media_url, + content: msg.content + }); + + // Verificar si es multimedia (simplificado) let contentHtml = ''; - if (msg.media_url) { + const isMultimedia = msg.media_url && msg.media_url.trim() !== '' && + msg.message_type && msg.message_type !== 'text'; + + if (isMultimedia) { + console.log('→ Renderizando como multimedia:', msg.message_type); // Mensaje multimedia - switch (msg.media_type) { + switch (msg.message_type) { case 'image': contentHtml = `Imagen`; break; @@ -586,6 +599,7 @@ if (empty($user_id)) { break; case 'audio': contentHtml = `