From d9f4b8d594608d0da7f3016522253ca8ec572fbf Mon Sep 17 00:00:00 2001 From: mkljczk Date: Wed, 25 Dec 2024 15:36:40 +0100 Subject: [PATCH] pl-api: support familiar followers on pixelfed Signed-off-by: mkljczk --- packages/pl-api/lib/client.ts | 17 +++++++++++++++-- packages/pl-api/lib/features.ts | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/pl-api/lib/client.ts b/packages/pl-api/lib/client.ts index a18c9fd2a..5c4524d9b 100644 --- a/packages/pl-api/lib/client.ts +++ b/packages/pl-api/lib/client.ts @@ -725,9 +725,22 @@ class PlApiClient { * @see {@link https://docs.joinmastodon.org/methods/accounts/#familiar_followers} */ getFamiliarFollowers: async (accountIds: string[]) => { - const response = await this.request('/api/v1/accounts/familiar_followers', { params: { id: accountIds } }); + let response: any; - return v.parse(filteredArray(familiarFollowersSchema), response.json); + if (this.features.version.software === PIXELFED) { + response = []; + for (const accountId of accountIds) { + const accounts = (await this.request(`/api/v1.1/accounts/mutuals/${accountId}`)).json; + response.push({ + id: accountId, + accounts, + }); + } + } else { + response = (await this.request('/api/v1/accounts/familiar_followers', { params: { id: accountIds } })).json; + } + + return v.parse(filteredArray(familiarFollowersSchema), response); }, /** diff --git a/packages/pl-api/lib/features.ts b/packages/pl-api/lib/features.ts index 6ec24c436..2faa5347f 100644 --- a/packages/pl-api/lib/features.ts +++ b/packages/pl-api/lib/features.ts @@ -569,6 +569,7 @@ const getFeatures = (instance: Instance) => { familiarFollowers: any([ v.software === DITTO, v.software === MASTODON, + v.software === PIXELFED, v.software === PLEROMA && gte(v.version, '2.6.0') && v.build === REBASED, v.software === PLEROMA && gte(v.version, '2.7.0'), v.software === TAKAHE,