Skip to content

best way to save what you love

api/twitter: handle empty body properly

wukko9639c599f0ed
diff --git a/api/src/processing/services/twitter.js b/api/src/processing/services/twitter.js
index b4a1d557..0f5f15e6 100644
--- a/api/src/processing/services/twitter.js
+++ b/api/src/processing/services/twitter.js
@@ -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();