Update Takahē compatibility, add fixVersion to instanceSchema
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
0658530447
commit
4752feb1b8
2 changed files with 33 additions and 1 deletions
|
@ -6,6 +6,25 @@ import { mrfSimpleSchema } from './pleroma';
|
|||
import { ruleSchema } from './rule';
|
||||
import { coerceObject, filteredArray, mimeSchema } from './utils';
|
||||
|
||||
const fixVersion = (version: string) => {
|
||||
// Handle Mastodon release candidates
|
||||
if (new RegExp(/[0-9.]+rc[0-9]+/g).test(version)) {
|
||||
version = version.split('rc').join('-rc');
|
||||
}
|
||||
|
||||
// Rename Akkoma to Pleroma+akkoma
|
||||
if (version.includes('Akkoma')) {
|
||||
version = '2.7.2 (compatible; Pleroma 2.4.50+akkoma)';
|
||||
}
|
||||
|
||||
// Set Takahē version to a Pleroma-like string
|
||||
if (version.startsWith('takahe/')) {
|
||||
version = `0.0.0 (compatible; Takahe ${version.slice(7)})`;
|
||||
}
|
||||
|
||||
return version;
|
||||
};
|
||||
|
||||
const configurationSchema = coerceObject({
|
||||
chats: coerceObject({
|
||||
max_characters: z.number().catch(5000),
|
||||
|
@ -136,6 +155,8 @@ const instanceSchema = coerceObject({
|
|||
}).transform(({ max_media_attachments, max_toot_chars, poll_limits, ...instance }) => {
|
||||
const { configuration } = instance;
|
||||
|
||||
const version = fixVersion(instance.version);
|
||||
|
||||
const polls = {
|
||||
...configuration.polls,
|
||||
max_characters_per_option: configuration.polls.max_characters_per_option ?? poll_limits.max_option_chars ?? 25,
|
||||
|
@ -157,6 +178,7 @@ const instanceSchema = coerceObject({
|
|||
polls,
|
||||
statuses,
|
||||
},
|
||||
version,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
@ -194,6 +194,7 @@ const getInstanceFeatures = (instance: Instance) => {
|
|||
announcements: any([
|
||||
v.software === MASTODON && gte(v.compatVersion, '3.1.0'),
|
||||
v.software === PLEROMA && gte(v.version, '2.2.49'),
|
||||
v.software === TAKAHE && gte(v.version, '0.7.0'),
|
||||
]),
|
||||
|
||||
/**
|
||||
|
@ -233,6 +234,7 @@ const getInstanceFeatures = (instance: Instance) => {
|
|||
v.software === MASTODON && gte(v.compatVersion, '3.1.0'),
|
||||
v.software === PLEROMA && gte(v.version, '0.9.9'),
|
||||
v.software === PIXELFED,
|
||||
v.software === TAKAHE && gte(v.version, '0.9.0'),
|
||||
]),
|
||||
|
||||
/**
|
||||
|
@ -366,9 +368,14 @@ const getInstanceFeatures = (instance: Instance) => {
|
|||
v.software === WILDEBEEST,
|
||||
]),
|
||||
|
||||
/**
|
||||
* Ability to edit published posts.
|
||||
* @see PUT /api/v1/statuses/:id
|
||||
*/
|
||||
editStatuses: any([
|
||||
v.software === FRIENDICA && gte(v.version, '2022.12.0'),
|
||||
v.software === MASTODON && gte(v.version, '3.5.0'),
|
||||
v.software === TAKAHE && gte(v.version, '0.8.0'),
|
||||
features.includes('editing'),
|
||||
]),
|
||||
|
||||
|
@ -491,6 +498,7 @@ const getInstanceFeatures = (instance: Instance) => {
|
|||
followHashtags: any([
|
||||
v.software === MASTODON && gte(v.compatVersion, '4.0.0'),
|
||||
v.software === PLEROMA && v.build === AKKOMA,
|
||||
v.software === TAKAHE && gte(v.version, '0.9.0'),
|
||||
]),
|
||||
|
||||
/**
|
||||
|
@ -677,6 +685,7 @@ const getInstanceFeatures = (instance: Instance) => {
|
|||
mutesDuration: any([
|
||||
v.software === PLEROMA && gte(v.version, '2.3.0'),
|
||||
v.software === MASTODON && gte(v.compatVersion, '3.3.0'),
|
||||
v.software === TAKAHE,
|
||||
]),
|
||||
|
||||
/**
|
||||
|
@ -732,6 +741,7 @@ const getInstanceFeatures = (instance: Instance) => {
|
|||
v.software === FIREFISH,
|
||||
v.software === MASTODON && gte(v.version, '2.8.0'),
|
||||
v.software === PLEROMA,
|
||||
v.software === TAKAHE && gte(v.version, '0.8.0'),
|
||||
v.software === TRUTHSOCIAL,
|
||||
]),
|
||||
|
||||
|
@ -758,6 +768,7 @@ const getInstanceFeatures = (instance: Instance) => {
|
|||
profileFields: any([
|
||||
v.software === MASTODON,
|
||||
v.software === PLEROMA,
|
||||
v.software === TAKAHE && gte(v.version, '0.7.0'),
|
||||
]),
|
||||
|
||||
/**
|
||||
|
@ -978,7 +989,6 @@ export const parseVersion = (version: string): Backend => {
|
|||
loose: true,
|
||||
}) : null;
|
||||
const compat = match ? semverParse(match[1]) || semverCoerce(match[1]) : null;
|
||||
|
||||
if (match && semver && compat) {
|
||||
return {
|
||||
build: semver.build[0],
|
||||
|
|
Loading…
Reference in a new issue