diff --git a/lib/routes/twitter/api/web-api/api.ts b/lib/routes/twitter/api/web-api/api.ts index cd3686d85..be9c908cc 100644 --- a/lib/routes/twitter/api/web-api/api.ts +++ b/lib/routes/twitter/api/web-api/api.ts @@ -84,21 +84,10 @@ const getUserTweetsAndReplies = (id: string, params?: Record) => ); const getUserMedia = (id: string, params?: Record) => - cacheTryGet(id, params, async (id, params = {}) => { - const cursorSource = await paginationTweets('UserMedia', id, { - ...params, - count: 20, - includePromotedContent: false, - withClientEventToken: false, - withBirdwatchNotes: false, - withVoice: true, - withV2Timeline: true, - }); - const cursor = cursorSource.find((i) => i.content?.cursorType === 'Top').content.value; - return gatherLegacyFromData( + cacheTryGet(id, params, async (id, params = {}) => + gatherLegacyFromData( await paginationTweets('UserMedia', id, { ...params, - cursor, count: 20, includePromotedContent: false, withClientEventToken: false, @@ -106,8 +95,8 @@ const getUserMedia = (id: string, params?: Record) => withVoice: true, withV2Timeline: true, }) - ); - }); + ) + ); const getUserLikes = (id: string, params?: Record) => cacheTryGet(id, params, async (id, params = {}) => diff --git a/lib/routes/twitter/api/web-api/constants.ts b/lib/routes/twitter/api/web-api/constants.ts index 1b9856ecb..b1ca1d46a 100644 --- a/lib/routes/twitter/api/web-api/constants.ts +++ b/lib/routes/twitter/api/web-api/constants.ts @@ -15,7 +15,7 @@ const graphQLEndpointsPlain = [ const gqlMap = Object.fromEntries(graphQLEndpointsPlain.map((endpoint) => [endpoint.split('/')[3].replace(/V2$|Query$|QueryV2$/, ''), endpoint])); -const thirdPartySupportedAPI = ['UserByScreenName', 'UserByRestId', 'UserTweets', 'UserTweetsAndReplies', 'ListLatestTweetsTimeline', 'SearchTimeline']; +const thirdPartySupportedAPI = ['UserByScreenName', 'UserByRestId', 'UserTweets', 'UserTweetsAndReplies', 'ListLatestTweetsTimeline', 'SearchTimeline', 'UserMedia']; const gqlFeatureUser = { hidden_profile_subscriptions_enabled: true, diff --git a/lib/routes/twitter/api/web-api/utils.ts b/lib/routes/twitter/api/web-api/utils.ts index 7d99d00b5..becf3f74a 100644 --- a/lib/routes/twitter/api/web-api/utils.ts +++ b/lib/routes/twitter/api/web-api/utils.ts @@ -270,8 +270,9 @@ export const paginationTweets = async (endpoint: string, userId: number | undefi const moduleItems = instructions.find((i) => i.type === 'TimelineAddToModule')?.moduleItems; const entries = instructions.find((i) => i.type === 'TimelineAddEntries')?.entries; + const gridEntries = entries.find((i) => i.entryId === 'profile-grid-0')?.content?.items; - return moduleItems || entries || []; + return gridEntries || moduleItems || entries || []; }; export function gatherLegacyFromData(entries: any[], filterNested?: string[], userId?: number | string) {