This commit is contained in:
Lizandro Guarnizo
2026-02-20 11:21:06 -05:00
parent c9ec58979e
commit 602e6d3724
11 changed files with 130 additions and 30 deletions
+2 -2
View File
@@ -77,7 +77,7 @@ try {
// Formatear mensajes
$conversations = array_map(function($msg) {
// Build external URL if available (media id -> api/get_media proxy)
$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;
$external = (isset($msg['media_url']) && $msg['media_url']) ? (preg_match('#^https?://#i', $msg['media_url']) ? $msg['media_url'] : ("api/version/media-url.php?id=" . urlencode($msg['media_url']))) : null;
// Fallback: if no external URL but content is JSON with link, extract it
$contentStr = $msg['content'] ?? '';
@@ -99,7 +99,7 @@ try {
foreach ($candidates as $cand) {
if ($cand) {
// if looks like id or url
$external = preg_match('#^https?://#i', $cand) ? $cand : (strpos($cand, 'http') === false ? "api/get_media.php?id=" . urlencode($cand) : $cand);
$external = preg_match('#^https?://#i', $cand) ? $cand : (strpos($cand, 'http') === false ? "api/version/media-url.php?id=" . urlencode($cand) : $cand);
break;
}
}
+1
View File
@@ -140,6 +140,7 @@ if ($mediaId) {
// ── Si no hay archivo local, descargar con MediaService y guardar como cache permanente ──
if ($mediaId) {
try {
set_time_limit(180); // Dar tiempo suficiente para fotos grandes (hasta 5MB)
require_once __DIR__ . '/../../classes/MediaService.php';
$ms = new MediaService();
$subdir = date('Y/m');
+1
View File
@@ -226,6 +226,7 @@ class WhatsAppWebhook {
$localThumb = null;
if (!empty($mediaUrl) && in_array($messageType, ['image', 'audio', 'video', 'document', 'sticker'])) {
try {
set_time_limit(180); // Tiempo extra para descargar media pesado
$mediaService = new MediaService();
$subdir = date('Y/m'); // Organizar por año/mes