diff --git a/src/embed/status.ts b/src/embed/status.ts index 384f99b..5d166ce 100644 --- a/src/embed/status.ts +++ b/src/embed/status.ts @@ -36,6 +36,17 @@ export const handleStatus = async ( const api = await statusAPI(status, language, event as FetchEvent, flags); const tweet = api?.tweet as APITweet; + /* If there was any errors fetching the Tweet, we'll return it */ + switch (api.code) { + case 401: + return returnError(Strings.ERROR_PRIVATE); + case 404: + return returnError(Strings.ERROR_TWEET_NOT_FOUND); + case 500: + console.log(api); + return returnError(Strings.ERROR_API_FAIL); + } + const isTelegram = (userAgent || '').indexOf('Telegram') > -1; /* Should sensitive posts be allowed Instant View? */ let useIV = @@ -65,17 +76,6 @@ export const handleStatus = async ( }; } - /* If there was any errors fetching the Tweet, we'll return it */ - switch (api.code) { - case 401: - return returnError(Strings.ERROR_PRIVATE); - case 404: - return returnError(Strings.ERROR_TWEET_NOT_FOUND); - case 500: - console.log(api); - 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 diff --git a/src/fetch.ts b/src/fetch.ts index 5c83dd1..79eb615 100644 --- a/src/fetch.ts +++ b/src/fetch.ts @@ -300,6 +300,10 @@ export const fetchConversation = async ( return true; } console.log('invalid graphql tweet'); + if (!tweet && typeof conversation.data?.tweetResult === 'object' && Object.keys(conversation.data?.tweetResult).length === 0) { + console.log('tweet was not found'); + return true; + } if (tweet?.__typename === 'TweetUnavailable' && tweet.reason === 'NsfwLoggedOut') { console.log('tweet is nsfw'); return true;