diff --git a/packages/pl-api/lib/client.ts b/packages/pl-api/lib/client.ts index 95cc68e51..54e3e7c11 100644 --- a/packages/pl-api/lib/client.ts +++ b/packages/pl-api/lib/client.ts @@ -404,6 +404,25 @@ class PlApiClient { }; }; + #paginatedIceshrimpAccountsList = async (url: string, fn: (body: T) => Array): Promise> => { + await this.#getIceshrimpAccessToken(); + + const response = (await this.request(url)); + const ids = fn(response.json); + + const accounts = await this.accounts.getAccounts(ids); + + const prevLink = getPrevLink(response); + const nextLink = getNextLink(response); + + return { + previous: prevLink ? () => this.#paginatedIceshrimpAccountsList(prevLink, fn) : null, + next: nextLink ? () => this.#paginatedIceshrimpAccountsList(nextLink, fn) : null, + items: accounts, + partial: response.status === 206, + }; + }; + #groupNotifications = ({ previous, next, items, ...response }: PaginatedResponse, params?: GetGroupedNotificationsParams): PaginatedResponse => { const notificationGroups: Array = []; @@ -988,8 +1007,15 @@ class PlApiClient { * * Requires features{@link Features.outgoingFollowRequests}. */ - getOutgoingFollowRequests: async (params?: GetFollowRequestsParams) => - this.#paginatedGet('/api/v1/pleroma/outgoing_follow_requests', { params }, accountSchema), + getOutgoingFollowRequests: async (params?: GetFollowRequestsParams) => { + if (this.features.version.software === ICESHRIMP_NET) { + return this.#paginatedIceshrimpAccountsList( + '/api/iceshrimp/follow_requests/outgoing', + (response: Array<{ user: {id: string } }>) => response.map(({ user }) => user.id), + ); + } + return this.#paginatedGet('/api/v1/pleroma/outgoing_follow_requests', { params }, accountSchema); + }, /** * Accept follow request diff --git a/packages/pl-api/lib/features.ts b/packages/pl-api/lib/features.ts index 3b3adf9db..a4cb60791 100644 --- a/packages/pl-api/lib/features.ts +++ b/packages/pl-api/lib/features.ts @@ -1223,7 +1223,10 @@ const getFeatures = (instance: Instance) => { /** * @see GET /api/v1/pleroma/outgoing_follow_requests */ - outgoingFollowRequests: v.build === PL && gte(v.version, '2.8.0'), + outgoingFollowRequests: any([ + v.software === ICESHRIMP_NET, + v.build === PL && gte(v.version, '2.8.0'), + ]), pleromaAdminAccounts: any([ v.software === AKKOMA,