mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-11 21:40:53 +01:00
Fix Telegram error handling
This commit is contained in:
parent
ef315bf6b5
commit
2380805732
2 changed files with 15 additions and 11 deletions
|
@ -36,6 +36,17 @@ export const handleStatus = async (
|
||||||
const api = await statusAPI(status, language, event as FetchEvent, flags);
|
const api = await statusAPI(status, language, event as FetchEvent, flags);
|
||||||
const tweet = api?.tweet as APITweet;
|
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;
|
const isTelegram = (userAgent || '').indexOf('Telegram') > -1;
|
||||||
/* Should sensitive posts be allowed Instant View? */
|
/* Should sensitive posts be allowed Instant View? */
|
||||||
let useIV =
|
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;
|
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
|
// Check if mediaNumber exists, and if that media exists in tweet.media.all. If it does, we'll store overrideMedia variable
|
||||||
|
|
|
@ -300,6 +300,10 @@ export const fetchConversation = async (
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
console.log('invalid graphql tweet');
|
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') {
|
if (tweet?.__typename === 'TweetUnavailable' && tweet.reason === 'NsfwLoggedOut') {
|
||||||
console.log('tweet is nsfw');
|
console.log('tweet is nsfw');
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue