From 6916004356dcd4375f65df37a7d5c021a54327c2 Mon Sep 17 00:00:00 2001 From: E1xP Date: Sat, 8 Aug 2026 13:43:37 +0800 Subject: [PATCH] fix(router/twitter): fix converstaion root post missing --- lib/routes/twitter/api/mobile-api/api.ts | 6 +++++- lib/routes/twitter/api/web-api/api.ts | 14 +++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/routes/twitter/api/mobile-api/api.ts b/lib/routes/twitter/api/mobile-api/api.ts index 9596ca8a878c..a1978f1bc28b 100644 --- a/lib/routes/twitter/api/mobile-api/api.ts +++ b/lib/routes/twitter/api/mobile-api/api.ts @@ -188,7 +188,11 @@ function gatherLegacyFromData(entries, filterNested?, userId?) { return tweets; } -const getUserTweetsByID = async (id, params = {}) => gatherLegacyFromData(await timelineTweets(id, params)); +const getUserTweetsByID = async (id, params = {}) => { + // Keep only root posts; drop replies and self-thread continuations from profile-conversation modules + const tweets = gatherLegacyFromData(await timelineTweets(id, params), ['profile-conversation-'], id); + return tweets.filter((t) => !t.in_reply_to_status_id_str); +}; // TODO: show the whole conversation instead of just the reply tweet const getUserTweetsAndRepliesByID = async (id, params = {}) => gatherLegacyFromData(await timelineTweetsAndReplies(id, params), ['profile-conversation-'], id); const getUserMediaByID = async (id, params = {}) => gatherLegacyFromData(await timelineMedia(id, params)); diff --git a/lib/routes/twitter/api/web-api/api.ts b/lib/routes/twitter/api/web-api/api.ts index f6bcc6f38e40..43a570febba4 100644 --- a/lib/routes/twitter/api/web-api/api.ts +++ b/lib/routes/twitter/api/web-api/api.ts @@ -53,8 +53,8 @@ const cacheTryGet = async (_id, params, operationName, func) => { }; const getUserTweets = (id: string, params?: Record) => - cacheTryGet(id, params, 'getUserTweets', async (id, params = {}) => - gatherLegacyFromData( + cacheTryGet(id, params, 'getUserTweets', async (id, params = {}) => { + const tweets = gatherLegacyFromData( await paginationTweets('UserTweets', id, { ...params, count: 20, @@ -62,9 +62,13 @@ const getUserTweets = (id: string, params?: Record) => withQuickPromoteEligibilityTweetFields: true, withVoice: true, withV2Timeline: true, - }) - ) - ); + }), + ['profile-conversation-'], + id + ); + // Keep only root posts; drop replies and self-thread continuations from profile-conversation modules + return tweets.filter((t) => !t.in_reply_to_status_id_str); + }); const getUserTweetsAndReplies = (id: string, params?: Record) => cacheTryGet(id, params, 'getUserTweetsAndReplies', async (id, params = {}) =>