api/twitter: handle 403 with no cookie in requestTweet()

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

View File

@ -89,14 +89,17 @@ const requestTweet = async(dispatcher, tweetId, token, cookie) => {
// we might have been missing the `ct0` cookie, retry // we might have been missing the `ct0` cookie, retry
if (result.status === 403 && result.headers.get('set-cookie')) { if (result.status === 403 && result.headers.get('set-cookie')) {
const cookieValues = cookie?.values();
if (cookieValues?.ct0) {
result = await fetch(graphqlTweetURL, { result = await fetch(graphqlTweetURL, {
headers: { headers: {
...headers, ...headers,
'x-csrf-token': cookie.values().ct0 'x-csrf-token': cookieValues.ct0
}, },
dispatcher dispatcher
}); });
} }
}
return result return result
} }