mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-13 06:11:00 +01:00
Bug fix fallback
This commit is contained in:
parent
57620d3004
commit
7dce798648
3 changed files with 5 additions and 5 deletions
|
@ -13,4 +13,4 @@ SENTRY_DSN = ""
|
||||||
SENTRY_AUTH_TOKEN = ""
|
SENTRY_AUTH_TOKEN = ""
|
||||||
SENTRY_ORG = ""
|
SENTRY_ORG = ""
|
||||||
SENTRY_PROJECT = ""
|
SENTRY_PROJECT = ""
|
||||||
API_FALLBACK_DOMAIN = ""
|
API_FALLBACK_DOMAIN = "https://"
|
|
@ -141,7 +141,7 @@ export const statusAPI = async (
|
||||||
language: string | undefined,
|
language: string | undefined,
|
||||||
event: FetchEvent
|
event: FetchEvent
|
||||||
): Promise<APIResponse> => {
|
): Promise<APIResponse> => {
|
||||||
const conversation = await fetchConversation(status, event);
|
let conversation = await fetchConversation(status, event);
|
||||||
let tweet = conversation?.globalObjects?.tweets?.[status] || {};
|
let tweet = conversation?.globalObjects?.tweets?.[status] || {};
|
||||||
|
|
||||||
if (tweet.retweeted_status_id_str) {
|
if (tweet.retweeted_status_id_str) {
|
||||||
|
@ -156,8 +156,8 @@ export const statusAPI = async (
|
||||||
if (conversation.timeline?.instructions?.length > 0) {
|
if (conversation.timeline?.instructions?.length > 0) {
|
||||||
// Try request again with fallback this time
|
// Try request again with fallback this time
|
||||||
console.log('No Tweet was found, trying fallback in case of geo-restriction');
|
console.log('No Tweet was found, trying fallback in case of geo-restriction');
|
||||||
const conversationFallback = await fetchConversation(status, event, true);
|
conversation = await fetchConversation(status, event, true);
|
||||||
tweet = conversationFallback?.globalObjects?.tweets?.[status] || {};
|
tweet = conversation?.globalObjects?.tweets?.[status] || {};
|
||||||
|
|
||||||
if (typeof tweet.full_text !== 'undefined') {
|
if (typeof tweet.full_text !== 'undefined') {
|
||||||
console.log('Successfully loaded Tweet, requiring fallback');
|
console.log('Successfully loaded Tweet, requiring fallback');
|
||||||
|
|
|
@ -125,7 +125,7 @@ export const twitterFetch = async (
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
/* We'll usually only hit this if we get an invalid response from Twitter.
|
/* We'll usually only hit this if we get an invalid response from Twitter.
|
||||||
It's uncommon, but it happens */
|
It's uncommon, but it happens */
|
||||||
console.error('Unknown error while fetching from API');
|
console.error('Unknown error while fetching from API', e);
|
||||||
event &&
|
event &&
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
cache.delete(guestTokenRequestCacheDummy.clone(), { ignoreMethod: true })
|
cache.delete(guestTokenRequestCacheDummy.clone(), { ignoreMethod: true })
|
||||||
|
|
Loading…
Add table
Reference in a new issue