From 371a62f1edeca9e7361871486f826a7cb46814c6 Mon Sep 17 00:00:00 2001 From: dangered wolf Date: Fri, 18 Aug 2023 16:17:22 -0400 Subject: [PATCH] Fix tweet.media accidentally being processed on error response --- src/embed/status.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/embed/status.ts b/src/embed/status.ts index 96ff371..502ec2f 100644 --- a/src/embed/status.ts +++ b/src/embed/status.ts @@ -56,13 +56,6 @@ export const handleStatus = async ( }; } - let overrideMedia: APIMedia | undefined; - - // Check if mediaNumber exists, and if that media exists in tweet.media.all. If it does, we'll store overrideMedia variable - if (mediaNumber && tweet.media && tweet.media.all && tweet.media.all[mediaNumber - 1]) { - overrideMedia = tweet.media.all[mediaNumber - 1]; - } - /* If there was any errors fetching the Tweet, we'll return it */ switch (api.code) { case 401: @@ -74,6 +67,13 @@ export const handleStatus = async ( return returnError(Strings.ERROR_API_FAIL); } + let overrideMedia: APIMedia | undefined; + + // Check if mediaNumber exists, and if that media exists in tweet.media.all. If it does, we'll store overrideMedia variable + if (mediaNumber && tweet.media && tweet.media.all && tweet.media.all[mediaNumber - 1]) { + overrideMedia = tweet.media.all[mediaNumber - 1]; + } + /* Catch direct media request (d.fxtwitter.com, or .mp4 / .jpg) */ if (flags?.direct && !flags?.textOnly && tweet.media) { let redirectUrl: string | null = null;