From 1064be6a7a42e7ec412f61116c91b95759f3d979 Mon Sep 17 00:00:00 2001 From: wukko Date: Thu, 22 Aug 2024 13:38:16 +0600 Subject: [PATCH] api/twitter: proxy thumbnails --- api/src/processing/services/twitter.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/api/src/processing/services/twitter.js b/api/src/processing/services/twitter.js index ec08fc6a..974db53c 100644 --- a/api/src/processing/services/twitter.js +++ b/api/src/processing/services/twitter.js @@ -180,12 +180,21 @@ export default async function({ id, index, toGif, dispatcher }) { isGif: media[0].type === "animated_gif" } default: + const proxyThumb = (url) => + createStream({ + service: "twitter", + type: "default", + u: url, + filename: `image.${new URL(url).pathname.split(".", 2)[1]}` + }) + const picker = media.map((content, i) => { if (content.type === "photo") { let url = `${content.media_url_https}?name=4096x4096`; return { type: "photo", url, + thumb: proxyThumb(url), } } @@ -207,7 +216,7 @@ export default async function({ id, index, toGif, dispatcher }) { return { type, url, - thumb: content.media_url_https + thumb: proxyThumb(content.media_url_https), } }); return { picker };