pl-api: add mastodon 4.5 stuff
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
20
packages/pl-api/lib/entities/async-refresh.ts
Normal file
20
packages/pl-api/lib/entities/async-refresh.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import * as v from 'valibot';
|
||||
|
||||
/**
|
||||
* @category Schemas
|
||||
* @see {@link https://docs.joinmastodon.org/entities/AsyncRefresh/}
|
||||
*/
|
||||
const asyncRefreshSchema = v.object({
|
||||
async_refresh: v.object({
|
||||
id: v.string(),
|
||||
status: v.picklist(['running', 'finished']),
|
||||
result_count: v.nullable(v.number()),
|
||||
}),
|
||||
});
|
||||
|
||||
/**
|
||||
* @category Entity types
|
||||
*/
|
||||
type AsyncRefresh = v.InferOutput<typeof asyncRefreshSchema>;
|
||||
|
||||
export { asyncRefreshSchema, type AsyncRefresh };
|
||||
@ -23,6 +23,7 @@ export * from './announcement';
|
||||
export * from './announcement-reaction';
|
||||
export * from './antenna';
|
||||
export * from './application';
|
||||
export * from './async-refresh';
|
||||
export * from './authorization-server-metadata';
|
||||
export * from './backup';
|
||||
export * from './bookmark-folder';
|
||||
|
||||
@ -161,6 +161,23 @@ const configurationSchema = coerceObject({
|
||||
translation: coerceObject({
|
||||
enabled: v.fallback(v.boolean(), false),
|
||||
}),
|
||||
timelines_access: coerceObject({
|
||||
...v.entriesFromList(
|
||||
['hashtag_feeds', 'trending_link_feeds'],
|
||||
coerceObject(
|
||||
v.entriesFromList(
|
||||
['local', 'remote'],
|
||||
v.fallback(v.picklist(['public', 'authenticated', 'disabled']), 'public'),
|
||||
),
|
||||
),
|
||||
),
|
||||
live_feeds: coerceObject(
|
||||
v.entriesFromList(
|
||||
['local', 'bubble', 'remote', 'wrenched'],
|
||||
v.fallback(v.picklist(['public', 'authenticated', 'disabled']), 'public'),
|
||||
),
|
||||
),
|
||||
}),
|
||||
urls: coerceObject({
|
||||
streaming: v.fallback(v.optional(v.pipe(v.string(), v.url())), undefined),
|
||||
status: v.fallback(v.optional(v.pipe(v.string(), v.url())), undefined),
|
||||
@ -358,6 +375,23 @@ const instanceSchema = v.pipe(
|
||||
};
|
||||
}
|
||||
|
||||
if (data.pleroma?.metadata?.restrict_unauthenticated?.timelines) {
|
||||
const timelines = data.pleroma.metadata.restrict_unauthenticated.timelines;
|
||||
const features = data.pleroma.metadata.features || [];
|
||||
|
||||
if (!data.configuration) data.configuration = {};
|
||||
|
||||
data.configuration.timelines_access = {
|
||||
...data.configuration.timelines_access,
|
||||
live_feeds: {
|
||||
bubble: timelines.bubble ? 'authenticated' : features.includes('bubble_timeline') ? 'public' : 'disabled',
|
||||
local: timelines.local ? 'authenticated' : 'public',
|
||||
remote: timelines.federated ? 'authenticated' : 'public',
|
||||
wrenched: timelines.wrenched ? 'authenticated' : features.includes('pleroma:wrenched_timeline') ? 'public' : 'disabled',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (data.domain) return { account_domain: data.domain, ...data, api_versions: apiVersions };
|
||||
|
||||
return { ...instanceV1ToV2(data), api_versions: apiVersions };
|
||||
|
||||
Reference in New Issue
Block a user