From e2b7622e15172e41d9cc964de0732925842a04a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicole=20Miko=C5=82ajczyk?= Date: Wed, 9 Apr 2025 10:11:36 +0200 Subject: [PATCH] pl-api: allow displaying subscribers list 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 | 9 +++++++++ packages/pl-api/lib/features.ts | 12 ++++++++++++ packages/pl-api/lib/params/accounts.ts | 9 +++++++++ packages/pl-fe/src/locales/en.json | 4 ++-- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/packages/pl-api/lib/client.ts b/packages/pl-api/lib/client.ts index ec02a8f2c..6c37f9cce 100644 --- a/packages/pl-api/lib/client.ts +++ b/packages/pl-api/lib/client.ts @@ -108,6 +108,7 @@ import type { GetAccountFollowingParams, GetAccountParams, GetAccountStatusesParams, + GetAccountSubscribersParams, GetRelationshipsParams, GetScrobblesParams, ReportAccountParams, @@ -594,6 +595,14 @@ class PlApiClient { getAccountFollowing: async (accountId: string, params?: GetAccountFollowingParams) => this.#paginatedGet(`/api/v1/accounts/${accountId}/following`, { params }, accountSchema), + /** + * Subscriptions to the given user. + * + * Requires features{@link Features['subscriptions']}. + */ + getAccountSubscribers: async (accountId: string, params?: GetAccountSubscribersParams) => + this.#paginatedGet(`/api/v1/accounts/${accountId}/subscribers`, { params }, accountSchema), + /** * Get account’s featured tags * Tags featured by this account. diff --git a/packages/pl-api/lib/features.ts b/packages/pl-api/lib/features.ts index 69d9561f9..ccebf53b3 100644 --- a/packages/pl-api/lib/features.ts +++ b/packages/pl-api/lib/features.ts @@ -1475,6 +1475,18 @@ const getFeatures = (instance: Instance) => { */ statusDislikes: v.software === FRIENDICA && gte(v.version, '2023.3.0'), + /** + * @see GET /api/v1/accounts/:id/subscribers + * @see POST /api/v1/subscriptions + * @see GET /api/v1/subscriptions/options + * @see POST /api/v1/subscriptions/options + * @see GET /api/v1/subscriptions/find + * @see POST /api/v1/subscriptions/invoices + * @see GET /api/v1/subscriptions/invoices/:id + * @see DELETE /api/v1/subscriptions/invoices/:id + */ + subscriptions: v.software === MITRA, + /** * Can display suggested accounts. * @see {@link https://docs.joinmastodon.org/methods/suggestions/} diff --git a/packages/pl-api/lib/params/accounts.ts b/packages/pl-api/lib/params/accounts.ts index c3c58c216..687c885e9 100644 --- a/packages/pl-api/lib/params/accounts.ts +++ b/packages/pl-api/lib/params/accounts.ts @@ -27,6 +27,14 @@ type GetAccountFollowersParams = PaginationParams & WithRelationshipsParam; */ type GetAccountFollowingParams = PaginationParams & WithRelationshipsParam; +/** + * @category Request params + */ +interface GetAccountSubscribersParams extends PaginationParams, WithRelationshipsParam { + /** Include expired subscriptions. */ + include_expired?: boolean; +} + /** * @category Request params */ @@ -111,6 +119,7 @@ export type { GetAccountStatusesParams, GetAccountFollowersParams, GetAccountFollowingParams, + GetAccountSubscribersParams, FollowAccountParams, GetRelationshipsParams, SearchAccountParams, diff --git a/packages/pl-fe/src/locales/en.json b/packages/pl-fe/src/locales/en.json index 3ce080f27..65fd5aac3 100644 --- a/packages/pl-fe/src/locales/en.json +++ b/packages/pl-fe/src/locales/en.json @@ -1436,10 +1436,10 @@ "security.qr.fail": "Failed to fetch setup key", "security.submit": "Save changes", "security.submit.delete": "Delete account", - "security.text.delete": "To delete your account, enter your password and then click Delete account. This is a permanent action that cannot be undone. Your account will be destroyed from this server, and a deletion request will be sent to other servers. It's not guaranteed that all servers will purge your account.", + "security.text.delete": "To delete your account, enter your password and then click Delete account. This is a permanent action that cannot be undone. Your account will be destroyed from this server, and a deletion request will be sent to other servers. It’s not guaranteed that all servers will purge your account.", "security.text.delete.local": "To delete your account, enter your password and then click Delete account. This is a permanent action that cannot be undone.", "security.text.delete.local.without_password": "To delete your account, click Delete account. This is a permanent action that cannot be undone.", - "security.text.delete.without_password": "To delete your account, click Delete account. This is a permanent action that cannot be undone. Your account will be destroyed from this server, and a deletion request will be sent to other servers. It's not guaranteed that all servers will purge your account.", + "security.text.delete.without_password": "To delete your account, click Delete account. This is a permanent action that cannot be undone. Your account will be destroyed from this server, and a deletion request will be sent to other servers. It’s not guaranteed that all servers will purge your account.", "security.tokens.created_at": "Created on {date}", "security.tokens.last_used": "Last used on {date}", "security.tokens.revoke": "Revoke",