From de9927ebef5c6659b1b688ee4afedb887a88bb8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicole=20Miko=C5=82ajczyk?= Date: Tue, 8 Apr 2025 15:09:15 +0200 Subject: [PATCH] pl-api: Support Mitra' import follows/followers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicole Mikołajczyk --- packages/pl-api/lib/client.ts | 20 ++++++++++++++++++++ packages/pl-api/lib/features.ts | 11 ++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/packages/pl-api/lib/client.ts b/packages/pl-api/lib/client.ts index e47c18dc9..11e9824c6 100644 --- a/packages/pl-api/lib/client.ts +++ b/packages/pl-api/lib/client.ts @@ -1537,6 +1537,12 @@ class PlApiClient { contentType: '', }); break; + case MITRA: + response = await this.request('/api/v1/settings/import_follows', { + method: 'POST', + body: { follows_csv: typeof list === 'string' ? list : await list.text() }, + }); + break; default: response = await this.request('/api/pleroma/follow_import', { method: 'POST', @@ -1548,6 +1554,20 @@ class PlApiClient { return response.json; }, + /** + * Move followers from remote alias. (experimental?) + * + * Requires features{@link Features['importFollowers']}. + */ + importFollowers: async (list: File | string, actorId: string) => { + const response = await this.request('/api/v1/settings/import_followers', { + method: 'POST', + body: { from_actor_id: actorId, followers_csv: typeof list === 'string' ? list : await list.text() }, + }); + + return response.json; + }, + /** * Imports your blocks. * diff --git a/packages/pl-api/lib/features.ts b/packages/pl-api/lib/features.ts index 3e7f231c0..a7e8d5231 100644 --- a/packages/pl-api/lib/features.ts +++ b/packages/pl-api/lib/features.ts @@ -832,15 +832,24 @@ const getFeatures = (instance: Instance) => { v.software === PLEROMA, ]), + /** + * Move followers from remote alias. + * @see POST /api/v1/settings/import_followers + */ + importFollowers: any([ + v.software === MITRA && gte(v.version, '2.18.0'), + ]), + /** * Import a .csv file with a list of followed users. * @see POST /api/pleroma/follow_import + * @see POST /api/v1/settings/import_follows * @see POST /api/v1/import - */ importFollows: any([ v.software === AKKOMA, v.software === GOTOSOCIAL && gte(v.version, '0.17.0'), + v.software === MITRA && gte(v.version, '1.10.0'), v.software === PLEROMA, ]),