api/twitter: handle empty body properly

This commit is contained in:
wukko 2025-03-11 10:00:24 +06:00
parent c346d2b027
commit 9639c599f0
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2

View file

@ -112,7 +112,17 @@ export default async function({ id, index, toGif, dispatcher, alwaysProxy }) {
// get new token & retry if old one expired
if ([403, 429].includes(tweet.status)) {
guestToken = await getGuestToken(dispatcher, true);
tweet = await requestTweet(dispatcher, id, guestToken)
if (cookie) {
tweet = await requestTweet(dispatcher, id, guestToken, cookie);
} else {
tweet = await requestTweet(dispatcher, id, guestToken);
}
}
const contentLength = tweet.headers.get("content-length");
if (!contentLength || tweet.headers.get("content-length") === '0') {
return { error: "content.post.unavailable" }
}
tweet = await tweet.json();