pl-api: support outgoing follow requests list on shrimpnet
Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -404,6 +404,25 @@ class PlApiClient {
|
||||
};
|
||||
};
|
||||
|
||||
#paginatedIceshrimpAccountsList = async <T> (url: string, fn: (body: T) => Array<string>): Promise<PaginatedResponse<Account>> => {
|
||||
await this.#getIceshrimpAccessToken();
|
||||
|
||||
const response = (await this.request<T>(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<Notification>, params?: GetGroupedNotificationsParams): PaginatedResponse<GroupedNotificationsResults, false> => {
|
||||
const notificationGroups: Array<NotificationGroup> = [];
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user