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 = `