From 01359ca5920031a7814979882bb888d526297137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sat, 25 Mar 2023 08:25:50 +0100 Subject: [PATCH 1/3] Update features.ts for Friendica MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/utils/features.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/soapbox/utils/features.ts b/app/soapbox/utils/features.ts index c07fe5b60..d488bcf9b 100644 --- a/app/soapbox/utils/features.ts +++ b/app/soapbox/utils/features.ts @@ -91,6 +91,8 @@ const getInstanceFeatures = (instance: Instance) => { const features = instance.pleroma.getIn(['metadata', 'features'], ImmutableList()) as ImmutableList; const federation = instance.pleroma.getIn(['metadata', 'federation'], ImmutableMap()) as ImmutableMap; + console.log(v); + return { /** * Can view and manage ActivityPub aliases through the API. @@ -150,6 +152,7 @@ const getInstanceFeatures = (instance: Instance) => { * @see POST /api/v1/accounts/:id/follow */ accountNotifies: any([ + v.software === FRIENDICA, v.software === MASTODON && gte(v.compatVersion, '3.3.0'), v.software === PLEROMA && gte(v.version, '2.4.50'), v.software === TRUTHSOCIAL, @@ -359,6 +362,7 @@ const getInstanceFeatures = (instance: Instance) => { ]), editStatuses: any([ + v.software === FRIENDICA, v.software === MASTODON && gte(v.version, '3.5.0'), features.includes('editing'), ]), @@ -432,6 +436,7 @@ const getInstanceFeatures = (instance: Instance) => { /** Whether the accounts who favourited or emoji-reacted to a status can be viewed through the API. */ exposableReactions: any([ + v.software === FRIENDICA, v.software === MASTODON, v.software === TAKAHE && gte(v.version, '0.6.1'), v.software === TRUTHSOCIAL, @@ -775,6 +780,7 @@ const getInstanceFeatures = (instance: Instance) => { * @see {@link https://docs.joinmastodon.org/methods/scheduled_statuses/} */ scheduledStatuses: any([ + v.software === FRIENDICA, v.software === MASTODON && gte(v.version, '2.7.0'), v.software === PLEROMA, ]), @@ -785,6 +791,7 @@ const getInstanceFeatures = (instance: Instance) => { * @see POST /api/v2/search */ searchFromAccount: any([ + v.software === FRIENDICA, v.software === MASTODON && gte(v.version, '2.8.0'), v.software === PLEROMA && gte(v.version, '1.0.0'), ]), @@ -853,7 +860,10 @@ const getInstanceFeatures = (instance: Instance) => { * Trending statuses. * @see GET /api/v1/trends/statuses */ - trendingStatuses: v.software === MASTODON && gte(v.compatVersion, '3.5.0'), + trendingStatuses: any([ + v.software === FRIENDICA, + v.software === MASTODON && gte(v.compatVersion, '3.5.0'), + ]), /** * Truth Social trending statuses API. @@ -866,6 +876,7 @@ const getInstanceFeatures = (instance: Instance) => { * @see GET /api/v1/trends */ trends: any([ + v.software === FRIENDICA, v.software === MASTODON && gte(v.compatVersion, '3.0.0'), v.software === TRUTHSOCIAL, ]), @@ -886,7 +897,10 @@ const getInstanceFeatures = (instance: Instance) => { * Whether the backend allows adding users you don't follow to lists. * @see POST /api/v1/lists/:id/accounts */ - unrestrictedLists: v.software === PLEROMA, + unrestrictedLists: any([ + v.software === FRIENDICA, + v.software === PLEROMA, + ]), }; }; From 52172c923fe499f281f544cdfe0588c962630e76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sat, 25 Mar 2023 09:43:27 +0100 Subject: [PATCH 2/3] Actually fix version parsing for Friendica MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/utils/features.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/app/soapbox/utils/features.ts b/app/soapbox/utils/features.ts index d488bcf9b..11e9182e3 100644 --- a/app/soapbox/utils/features.ts +++ b/app/soapbox/utils/features.ts @@ -91,8 +91,6 @@ const getInstanceFeatures = (instance: Instance) => { const features = instance.pleroma.getIn(['metadata', 'features'], ImmutableList()) as ImmutableList; const federation = instance.pleroma.getIn(['metadata', 'federation'], ImmutableMap()) as ImmutableMap; - console.log(v); - return { /** * Can view and manage ActivityPub aliases through the API. @@ -152,7 +150,6 @@ const getInstanceFeatures = (instance: Instance) => { * @see POST /api/v1/accounts/:id/follow */ accountNotifies: any([ - v.software === FRIENDICA, v.software === MASTODON && gte(v.compatVersion, '3.3.0'), v.software === PLEROMA && gte(v.version, '2.4.50'), v.software === TRUTHSOCIAL, @@ -791,7 +788,6 @@ const getInstanceFeatures = (instance: Instance) => { * @see POST /api/v2/search */ searchFromAccount: any([ - v.software === FRIENDICA, v.software === MASTODON && gte(v.version, '2.8.0'), v.software === PLEROMA && gte(v.version, '1.0.0'), ]), @@ -897,10 +893,7 @@ const getInstanceFeatures = (instance: Instance) => { * Whether the backend allows adding users you don't follow to lists. * @see POST /api/v1/lists/:id/accounts */ - unrestrictedLists: any([ - v.software === FRIENDICA, - v.software === PLEROMA, - ]), + unrestrictedLists: v.software === PLEROMA, }; }; @@ -933,7 +926,9 @@ export const parseVersion = (version: string): Backend => { const match = regex.exec(version); const semverString = match && (match[3] || match[1]); - const semver = match ? semverParse(semverString) || semverCoerce(semverString) : null; + const semver = match ? semverParse(semverString) || semverCoerce(semverString, { + loose: true, + }) : null; const compat = match ? semverParse(match[1]) || semverCoerce(match[1]) : null; if (match && semver && compat) { From 4990e1eaa75c9e15bc025c82fe76c8b5922b100f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sat, 25 Mar 2023 10:02:21 +0100 Subject: [PATCH 3/3] Check version for Friendica features MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/utils/features.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/soapbox/utils/features.ts b/app/soapbox/utils/features.ts index 11e9182e3..b9d0e2210 100644 --- a/app/soapbox/utils/features.ts +++ b/app/soapbox/utils/features.ts @@ -359,7 +359,7 @@ const getInstanceFeatures = (instance: Instance) => { ]), editStatuses: any([ - v.software === FRIENDICA, + v.software === FRIENDICA && gte(v.version, '2022.12.0'), v.software === MASTODON && gte(v.version, '3.5.0'), features.includes('editing'), ]), @@ -857,7 +857,7 @@ const getInstanceFeatures = (instance: Instance) => { * @see GET /api/v1/trends/statuses */ trendingStatuses: any([ - v.software === FRIENDICA, + v.software === FRIENDICA && gte(v.version, '2022.12.0'), v.software === MASTODON && gte(v.compatVersion, '3.5.0'), ]), @@ -872,7 +872,7 @@ const getInstanceFeatures = (instance: Instance) => { * @see GET /api/v1/trends */ trends: any([ - v.software === FRIENDICA, + v.software === FRIENDICA && gte(v.version, '2022.12.0'), v.software === MASTODON && gte(v.compatVersion, '3.0.0'), v.software === TRUTHSOCIAL, ]),