mirror of
https://github.com/wukko/cobalt.git
synced 2025-04-30 14:34:27 +02:00
api/twitter: handle empty body properly
This commit is contained in:
parent
c346d2b027
commit
9639c599f0
@ -112,7 +112,17 @@ export default async function({ id, index, toGif, dispatcher, alwaysProxy }) {
|
|||||||
// get new token & retry if old one expired
|
// get new token & retry if old one expired
|
||||||
if ([403, 429].includes(tweet.status)) {
|
if ([403, 429].includes(tweet.status)) {
|
||||||
guestToken = await getGuestToken(dispatcher, true);
|
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();
|
tweet = await tweet.json();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user