This commit is contained in:
lizandrogd
2026-01-21 12:37:26 -05:00
parent 3f6e723fac
commit 43e54a55c0
4 changed files with 84 additions and 24 deletions
+17 -1
View File
@@ -81,6 +81,22 @@ try {
// Formatear fechas y limpiar datos
$conversations = array_map(function($msg) {
$external = (isset($msg['media_url']) && $msg['media_url']) ? (preg_match('#^https?://#i', $msg['media_url']) ? $msg['media_url'] : ("api/get_media.php?id=" . urlencode($msg['media_url']))) : null;
$contentStr = $msg['content'] ?? '';
if (!$external && $contentStr) {
$j = json_decode($contentStr, true);
if (is_array($j)) {
foreach (['image','document','audio','video'] as $k) {
if (isset($j[$k]) && is_array($j[$k])) {
if (!empty($j[$k]['link'])) { $external = $j[$k]['link']; break; }
if (!empty($j[$k]['url'])) { $external = $j[$k]['url']; break; }
if (!empty($j[$k]['id'])) { $external = "api/get_media.php?id=" . urlencode($j[$k]['id']); break; }
}
}
if (!$external && !empty($j['link'])) $external = $j['link'];
}
}
return [
'id' => intval($msg['id']),
'user_id' => intval($msg['user_id']),
@@ -89,7 +105,7 @@ try {
'media_url' => null,
'local_file' => $msg['local_file'] ?? null,
'local_thumb' => $msg['local_thumb'] ?? null,
'media_url_external' => (isset($msg['media_url']) && $msg['media_url']) ? (preg_match('#^https?://#i', $msg['media_url']) ? $msg['media_url'] : ("api/get_media.php?id=" . urlencode($msg['media_url']))) : null,
'media_url_external' => $external,
'filename' => $msg['filename'] ?? null,
'mime_type' => $msg['mime_type'] ?? null,
'user_phone' => $msg['user_phone'] ?? null,