diff --git a/lib/v2/twitter/web-api/twitter-api.js b/lib/v2/twitter/web-api/twitter-api.js index d153da5a0c523b..9c912adef03a85 100644 --- a/lib/v2/twitter/web-api/twitter-api.js +++ b/lib/v2/twitter/web-api/twitter-api.js @@ -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;