Fix tweet.media accidentally being processed on error response

This commit is contained in:
dangered wolf 2023-08-18 16:17:22 -04:00
parent 329fe35eec
commit 371a62f1ed
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58

View file

@ -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;