Bugfix, prettier

This commit is contained in:
dangered wolf 2022-08-28 15:26:31 -04:00
parent e95ec915f2
commit 9fe1a2e3c3
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58
2 changed files with 14 additions and 8 deletions

View file

@ -125,7 +125,10 @@ export const fetchUsingGuest = async (
/* We'll usually only hit this if we get an invalid response from Twitter.
It's uncommon, but it happens */
console.error('Unknown error while fetching conversation from API');
event && event.waitUntil(cache.delete(guestTokenRequestCacheDummy.clone(), { ignoreMethod: true }));
event &&
event.waitUntil(
cache.delete(guestTokenRequestCacheDummy.clone(), { ignoreMethod: true })
);
newTokenGenerated = true;
continue;
}
@ -137,14 +140,16 @@ export const fetchUsingGuest = async (
/* Running out of requests within our rate limit, let's purge the cache */
if (remainingRateLimit < 20) {
console.log(`Purging token on this edge due to low rate limit remaining`);
event && event.waitUntil(cache.delete(guestTokenRequestCacheDummy.clone(), { ignoreMethod: true }));
event &&
event.waitUntil(
cache.delete(guestTokenRequestCacheDummy.clone(), { ignoreMethod: true })
);
}
if (
typeof conversation.globalObjects === 'undefined' &&
(typeof conversation.errors === 'undefined' ||
conversation.errors?.[0]?.code ===
239) /* Error 239 = Bad guest token */
conversation.errors?.[0]?.code === 239) /* Error 239 = Bad guest token */
) {
console.log('Failed to fetch conversation, got', conversation);
newTokenGenerated = true;

View file

@ -186,15 +186,16 @@ export const handleStatus = async (
/* This Tweet has one or more photos to render */
if (tweet.media?.photos) {
const { photos } = tweet.media;
let photo = photos[(mediaNumber || 1) - 1];
let photo: APIPhoto | APIMosaicPhoto = photos[(mediaNumber || 1) - 1];
/* If there isn't a specified media number and we have a
mosaic response, we'll render it using mosaic */
if (typeof mediaNumber !== 'number' && tweet.media.mosaic) {
photo = {
/* Include dummy height/width for TypeScript reasons. We have a check to make sure we don't use these later. */
height: 0,
width: 0,
url: tweet.media.mosaic.formats.jpeg,
width: tweet.media.mosaic.width,
height: tweet.media.mosaic.height,
type: 'photo'
};
/* If mosaic isn't available or the link calls for a specific photo,
@ -220,7 +221,7 @@ export const handleStatus = async (
/* Push the raw photo-related headers */
headers.push(
`<meta name="twitter:image" content="${photo.url}"/>`,
`<meta name="og:image" content="${photo.url}"/>`,
`<meta name="og:image" content="${photo.url}"/>`
);
if (!tweet.media.mosaic) {