pl-api: support blocks duration

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2025-11-11 12:59:05 +01:00
parent a0e967cb54
commit 2f586a996b
3 changed files with 20 additions and 3 deletions

View File

@ -181,6 +181,7 @@ import type {
GetJoinedEventsParams,
} from './params/events';
import type {
BlockAccountParams,
CreateFilterParams,
GetBlocksParams,
GetDomainBlocksParams,
@ -2050,9 +2051,10 @@ class PlApiClient {
* Block account
* Block the given account. Clients should filter statuses from this account if received (e.g. due to a boost in the Home timeline)
* @see {@link https://docs.joinmastodon.org/methods/accounts/#block}
* `duration` parameter requires features{@link Features.blocksDuration}.
*/
blockAccount: async (accountId: string) => {
const response = await this.request(`/api/v1/accounts/${accountId}/block`, { method: 'POST' });
blockAccount: async (accountId: string, params?: BlockAccountParams) => {
const response = await this.request(`/api/v1/accounts/${accountId}/block`, { method: 'POST', body: params });
return v.parse(relationshipSchema, response.json);
},
@ -2461,7 +2463,7 @@ class PlApiClient {
* Delete a status
* Delete one of your own statuses.
*
* `delete_media` parameters requires features{@link Features.deleteMedia}.
* `delete_media` parameter requires features{@link Features.deleteMedia}.
* @see {@link https://docs.joinmastodon.org/methods/statuses/#delete}
*/
deleteStatus: async (statusId: string, deleteMedia?: boolean) => {

View File

@ -420,6 +420,12 @@ const getFeatures = (instance: Instance) => {
/** Whether people who blocked you are visible through the API. */
blockersVisible: instance.api_versions['blockers_visible.pleroma.pl-api'] >= 1,
/**
* Ability to specify how long the account block should last.
* @see PUT /api/v1/accounts/:id/block
*/
blocksDuration: instance.api_versions['block_expiration.pleroma.pl-api'] >= 1,
bookmarkFolderEmojis: instance.api_versions['bookmark_folders.pleroma.pl-api'] >= 1,
/**

View File

@ -1,5 +1,13 @@
import type { PaginationParams, WithRelationshipsParam } from './common';
/**
* @category Request params
*/
interface BlockAccountParams {
/** Number. How long the block should last, in seconds. Defaults to 0 (indefinite). */
duration?: number;
}
/**
* @category Request params
*/
@ -61,6 +69,7 @@ interface UpdateFilterParams {
}
export type {
BlockAccountParams,
MuteAccountParams,
GetMutesParams,
GetBlocksParams,