Skip to content

Commit

Permalink
fix: twitter cookie deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Jul 13, 2024
1 parent 7cd8d2d commit c133dbb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/routes/twitter/api/web-api/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,18 @@ export const twitterGot = async (url, params) => {
'x-csrf-token': jsonCookie.ct0,
},
dispatcher: dispatchers[token].agent,
onResponse: async ({ response }) => {
if (response.status === 403) {
logger.debug(`Delete twitter cookie for token ${token}`);
await cache.set(`twitter:cookie:${token}`, '', config.cache.contentExpire);
}
},
});

if (token) {
logger.debug(`Reset twitter cookie for token ${token}`);
await cache.set(`twitter:cookie:${token}`, JSON.stringify(dispatchers[token].jar.serializeSync()), config.cache.contentExpire);
}
if (response.status === 403) {
logger.debug(`Delete twitter cookie for token ${token}`);
await cache.set(`twitter:cookie:${token}`, '', config.cache.contentExpire);
}

return response._data;
};
Expand Down

0 comments on commit c133dbb

Please sign in to comment.