Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/routes/twitter/api/mobile-api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
14 changes: 9 additions & 5 deletions lib/routes/twitter/api/web-api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,22 @@ const cacheTryGet = async (_id, params, operationName, func) => {
};

const getUserTweets = (id: string, params?: Record<string, any>) =>
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,
includePromotedContent: true,
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<string, any>) =>
cacheTryGet(id, params, 'getUserTweetsAndReplies', async (id, params = {}) =>
Expand Down