From 551814a72836d0596f91951cb30719cb4503eb36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicole=20Miko=C5=82ajczyk?= Date: Tue, 22 Apr 2025 10:50:24 +0200 Subject: [PATCH] pl-api: wip bookmark folders on kmyblue 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 | 15 ++++++++++++++- packages/pl-api/lib/features.ts | 4 +++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/pl-api/lib/client.ts b/packages/pl-api/lib/client.ts index c6effa8cf..c82f31a22 100644 --- a/packages/pl-api/lib/client.ts +++ b/packages/pl-api/lib/client.ts @@ -2352,6 +2352,10 @@ class PlApiClient { bookmarkStatus: async (statusId: string, folderId?: string) => { const response = await this.request(`/api/v1/statuses/${statusId}/bookmark`, { method: 'POST', body: { folder_id: folderId } }); + if (folderId && this.features.bookmarkFoldersMultiple) { + await this.request(`/api/v1/bookmark_categories/${folderId}/statuses`, { method: 'POST', params: { status_ids: [statusId] } }); + } + return v.parse(statusSchema, response.json); }, @@ -2571,13 +2575,22 @@ class PlApiClient { /** * Load conversation from a remote server. * - * Requires features{@link Features['loadConversation']}. + * Requires features{@link Features.loadConversation}. */ loadConversation: async (statusId: string) => { const response = await this.request <{}>(`/api/v1/statuses/${statusId}/load_conversation`, { method: 'POST' }); return response.json; }, + + /** + * Requires features{@link Features.bookmarkFoldersMultiple}. + */ + getStatusBookmarkFolders: async (statusId: string) => { + const response = await this.request(`/api/v1/statuses/${statusId}/categories`, { method: 'GET' }); + + return v.parse(filteredArray(bookmarkFolderSchema), response.json); + }, }; public readonly media = { diff --git a/packages/pl-api/lib/features.ts b/packages/pl-api/lib/features.ts index 6a481d0ce..fcce14ae0 100644 --- a/packages/pl-api/lib/features.ts +++ b/packages/pl-api/lib/features.ts @@ -366,6 +366,8 @@ const getFeatures = (instance: Instance) => { /** Whether people who blocked you are visible through the API. */ blockersVisible: instance.api_versions['blockers_visible.pleroma.pl-api'] >= 1, + bookmarkFolderEmojis: instance.api_versions['bookmark_folders.pleroma.pl-api'] >= 1, + /** * Can group bookmarks in folders. * @see GET /api/v1/pleroma/bookmark_folders @@ -378,7 +380,7 @@ const getFeatures = (instance: Instance) => { instance.api_versions['kmyblue_bookmark_category.fedibird.pl-api'] >= 1, ]), - bookmarkFolderEmojis: instance.api_versions['bookmark_folders.pleroma.pl-api'] >= 1, + bookmarkFoldersMultiple: instance.api_versions['kmyblue_bookmark_category.fedibird.pl-api'] >= 1, /** * Can bookmark statuses.