fix(route/twitter/web-api): excludeReplies=1 (#14290)
Fixes #14285 The postprocessing that removes replies accidentally removed all tweets except for the first one after the recent Twitter update. Signed-off-by: Rongrong <i@rong.moe>
This commit is contained in:
parent
cd48da470e
commit
e8a33d80fa
|
|
@ -258,9 +258,12 @@ const getUserTweets = async (cache, id, params = {}) => {
|
|||
const idSet = new Set();
|
||||
tweets = tweets
|
||||
.filter((tweet) => !tweet.in_reply_to_screen_name) // exclude replies
|
||||
.map((tweet) => (idSet.has(tweet.id_str) ? null : idSet.add(tweet.id_str)) && tweet) // deduplicate
|
||||
.map((tweet) => {
|
||||
const id_str = tweet.id_str || tweet.conversation_id_str;
|
||||
return !idSet.has(id_str) && idSet.add(id_str) && tweet;
|
||||
}) // deduplicate
|
||||
.filter(Boolean) // remove null
|
||||
.sort((a, b) => b.id_str - a.id_str) // desc
|
||||
.sort((a, b) => (b.id_str || b.conversation_id_str) - (a.id_str || a.conversation_id_str)) // desc
|
||||
.slice(0, 20);
|
||||
cache.set(cacheKey, JSON.stringify(tweets));
|
||||
return tweets;
|
||||
|
|
|
|||
Loading…
Reference in New Issue