pl-api: allow to favourite lists
Signed-off-by: mkljczk <git@mkljczk.pl>
This commit is contained in:
@ -2598,6 +2598,28 @@ class PlApiClient {
|
||||
|
||||
return response.json as {};
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a list to favourites
|
||||
*
|
||||
* Requires features{@link Features['listsFavourite']}.
|
||||
*/
|
||||
favouriteList: async (listId: string) => {
|
||||
const response = await this.request(`/api/v1/lists/${listId}/favourite`, { method: 'POST' });
|
||||
|
||||
return v.parse(listSchema, response.json);
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove a list from favourites
|
||||
*
|
||||
* Requires features{@link Features['listsFavourite']}.
|
||||
*/
|
||||
unfavouriteList: async (listId: string) => {
|
||||
const response = await this.request(`/api/v1/lists/${listId}/unfavourite`, { method: 'POST' });
|
||||
|
||||
return v.parse(listSchema, response.json);
|
||||
},
|
||||
};
|
||||
|
||||
public readonly streaming = {
|
||||
|
||||
@ -1,11 +1,8 @@
|
||||
import * as v from 'valibot';
|
||||
|
||||
import { listSchema } from './list';
|
||||
import { type List, listSchema } from './list';
|
||||
|
||||
/**
|
||||
* @category Schemas
|
||||
*/
|
||||
const antennaSchema = v.object({
|
||||
const baseAntennaSchema = v.object({
|
||||
id: v.string(),
|
||||
title: v.string(),
|
||||
with_media_only: v.boolean(),
|
||||
@ -13,7 +10,6 @@ const antennaSchema = v.object({
|
||||
stl: v.boolean(),
|
||||
ltl: v.boolean(),
|
||||
insert_feeds: v.boolean(),
|
||||
list: v.nullable(listSchema),
|
||||
accounts_count: v.number(),
|
||||
domains_count: v.number(),
|
||||
tags_count: v.number(),
|
||||
@ -21,9 +17,19 @@ const antennaSchema = v.object({
|
||||
favourite: v.boolean(),
|
||||
});
|
||||
|
||||
/**
|
||||
* @category Schemas
|
||||
*/
|
||||
const antennaSchema: v.BaseSchema<any, Antenna, v.BaseIssue<unknown>> = v.object({
|
||||
...baseAntennaSchema.entries,
|
||||
list: v.fallback(v.nullable(v.lazy(() => listSchema)), null),
|
||||
});
|
||||
|
||||
/**
|
||||
* @category Entity types
|
||||
*/
|
||||
type Antenna = v.InferOutput<typeof antennaSchema>;
|
||||
type Antenna = v.InferOutput<typeof baseAntennaSchema> & {
|
||||
list: List | null;
|
||||
}
|
||||
|
||||
export { antennaSchema, type Antenna };
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
import * as v from 'valibot';
|
||||
|
||||
import { antennaSchema } from './antenna';
|
||||
import { filteredArray } from './utils';
|
||||
|
||||
/**
|
||||
* @category Schemas
|
||||
* @see {@link https://docs.joinmastodon.org/entities/List/}
|
||||
@ -9,6 +12,9 @@ const listSchema = v.object({
|
||||
title: v.string(),
|
||||
replies_policy: v.fallback(v.optional(v.string()), undefined),
|
||||
exclusive: v.fallback(v.optional(v.boolean()), undefined),
|
||||
antennas: filteredArray(antennaSchema),
|
||||
notify: v.fallback(v.optional(v.boolean()), undefined),
|
||||
favourite: v.fallback(v.optional(v.boolean()), undefined),
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@ -781,6 +781,13 @@ const getFeatures = (instance: Instance) => {
|
||||
v.software === PLEROMA,
|
||||
]),
|
||||
|
||||
/**
|
||||
* Can add a list to favourites.
|
||||
* @see POST /api/v1/lists/:list_id/favourite
|
||||
* @see POST /api/v1/lists/:list_id/unfavourite
|
||||
*/
|
||||
listsFavourites: instance.api_versions['favourite_list.fedibird.pl-api'] >= 1,
|
||||
|
||||
/**
|
||||
* Ability to post statuses that don't federate.
|
||||
* @see POST /api/v1/statuses
|
||||
|
||||
Reference in New Issue
Block a user