This commit is contained in:
lizandrogd
2026-01-21 14:17:04 -05:00
parent b202c039b1
commit 16591537c7
2 changed files with 17 additions and 1 deletions
+3
View File
@@ -9,3 +9,6 @@
[2026-01-21 14:09:48] Request: GET /api/version/media-url.php?id=2690520987949889 GET:{"id":"2690520987949889"} POST:[]
[2026-01-21 14:09:48] Graph API request to https://graph.facebook.com/v22.0/2690520987949889
[2026-01-21 14:09:49] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=2690520987949889&source=getMedia&ext=1769022879&hash=ARmZNGo6nPUMqsu1WVi5OGDOIQucpHkU45UcMnR0kudP2Q
[2026-01-21 14:14:06] Request: GET /api/version/media-url.php?id=3932473397057815 GET:{"id":"3932473397057815"} POST:[]
[2026-01-21 14:14:06] Graph API request to https://graph.facebook.com/v22.0/3932473397057815
[2026-01-21 14:14:07] Proxying Facebook media URL with Authorization to https://lookaside.fbsbx.com/whatsapp_business/attachments/?mid=3932473397057815&source=getMedia&ext=1769023137&hash=ARlu_MCLx6NJCX8mxWXoqSxQ5jNO5lfqPV3wj5mAfq0qAQ
+14 -1
View File
@@ -613,7 +613,20 @@ if (empty($user_id)) {
} else if (isValidMediaUrl(msg.local_file)) {
thumbUrl = `/${msg.local_file}`;
} else if (isValidMediaUrl(msg.media_url_external)) {
thumbUrl = msg.media_url_external;
// Si es una URL externa de Facebook/lookaside, usar el proxy para incluir Authorization
const external = msg.media_url_external;
if (/lookaside\.fbsbx\.com|graph\.facebook\.com|facebook\.com/i.test(external)) {
// Intentar extraer mid del query string para usar ?id=
const midMatch = external.match(/[?&]mid=([^&]+)/i);
if (midMatch && midMatch[1]) {
const mid = decodeURIComponent(midMatch[1]);
thumbUrl = `/api/version/media-url.php?id=${encodeURIComponent(mid)}`;
} else {
thumbUrl = `/api/version/media-url.php?url=${encodeURIComponent(external)}`;
}
} else {
thumbUrl = external;
}
} else if (isValidMediaUrl(msg.media_url)) {
thumbUrl = msg.media_url;
}