mirror of
https://github.com/wukko/cobalt.git
synced 2025-03-26 11:14:44 +01:00
api/twitter: handle empty body properly
This commit is contained in:
parent
c346d2b027
commit
9639c599f0
1 changed files with 11 additions and 1 deletions
|
@ -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…
Add table
Reference in a new issue