Features: sort keys alphabetically

revert-5af0e40a
Alex Gleason 2 years ago
parent ab2e6b2ee3
commit 677327336f
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

@ -1,3 +1,4 @@
/* eslint sort-keys: "error" */
import { List as ImmutableList, Map as ImmutableMap } from 'immutable'; import { List as ImmutableList, Map as ImmutableMap } from 'immutable';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import gte from 'semver/functions/gte'; import gte from 'semver/functions/gte';
@ -51,122 +52,117 @@ const getInstanceFeatures = (instance: Instance) => {
return { return {
/** /**
* Can upload media attachments to statuses. * Can view and manage ActivityPub aliases through the API.
* @see POST /api/v1/media * @see GET /api/pleroma/aliases
* @see POST /api/v1/statuses * @see PATCH /api/v1/accounts/update_credentials
*/ */
media: true, accountAliasesAPI: v.software === PLEROMA,
/** /**
* Can set privacy scopes on statuses. * The accounts API allows an acct instead of an ID.
* @see POST /api/v1/statuses * @see GET /api/v1/accounts/:acct_or_id
*/ */
privacyScopes: v.software !== TRUTHSOCIAL, accountByUsername: v.software === PLEROMA,
/** /**
* Can set content warnings on statuses. * Ability to pin other accounts on one's profile.
* @see POST /api/v1/statuses * @see POST /api/v1/accounts/:id/pin
* @see POST /api/v1/accounts/:id/unpin
* @see GET /api/v1/pleroma/accounts/:id/endorsements
*/ */
spoilers: v.software !== TRUTHSOCIAL, accountEndorsements: v.software === PLEROMA && gte(v.version, '2.4.50'),
/** /**
* Can edit and manage timeline filters (aka "muted words"). * Ability to set one's location on their profile.
* @see {@link https://docs.joinmastodon.org/methods/accounts/filters/} * @see PATCH /api/v1/accounts/update_credentials
*/ */
filters: v.software !== TRUTHSOCIAL, accountLocation: v.software === TRUTHSOCIAL,
/** /**
* Can add polls to statuses. * Look up an account by the acct.
* @see POST /api/v1/statuses * @see GET /api/v1/accounts/lookup
*/ */
polls: any([ accountLookup: any([
v.software === MASTODON && gte(v.version, '2.8.0'), v.software === MASTODON && gte(v.compatVersion, '3.4.0'),
v.software === PLEROMA, v.software === PLEROMA && gte(v.version, '2.4.50'),
]), ]),
/** /**
* Can schedule statuses to be posted at a later time. * Move followers to a different ActivityPub account.
* @see POST /api/v1/statuses * @see POST /api/pleroma/move_account
* @see {@link https://docs.joinmastodon.org/methods/statuses/scheduled_statuses/}
*/ */
scheduledStatuses: any([ accountMoving: v.software === PLEROMA && gte(v.version, '2.4.50'),
v.software === MASTODON && gte(v.version, '2.7.0'),
v.software === PLEROMA,
]),
/** /**
* Can bookmark statuses. * Ability to subscribe to notifications every time an account posts.
* @see POST /api/v1/statuses/:id/bookmark * @see POST /api/v1/accounts/:id/follow
* @see GET /api/v1/bookmarks
*/ */
bookmarks: any([ accountNotifies: any([
v.software === MASTODON && gte(v.compatVersion, '3.1.0'), v.software === MASTODON && gte(v.compatVersion, '3.3.0'),
v.software === PLEROMA && gte(v.version, '0.9.9'), v.software === PLEROMA && gte(v.version, '2.4.50'),
v.software === PIXELFED,
]), ]),
/** /**
* Can create, view, and manage lists. * Ability to subscribe to notifications every time an account posts.
* @see {@link https://docs.joinmastodon.org/methods/timelines/lists/} * @see POST /api/v1/pleroma/accounts/:id/subscribe
* @see GET /api/v1/timelines/list/:list_id * @see POST /api/v1/pleroma/accounts/:id/unsubscribe
*/ */
lists: any([ accountSubscriptions: v.software === PLEROMA && gte(v.version, '1.0.0'),
v.software === MASTODON && gte(v.compatVersion, '2.1.0'),
v.software === PLEROMA && gte(v.version, '0.9.9'),
]),
/** /**
* Can display suggested accounts. * Ability to set one's website on their profile.
* @see {@link https://docs.joinmastodon.org/methods/accounts/suggestions/} * @see PATCH /api/v1/accounts/update_credentials
*/ */
suggestions: any([ accountWebsite: v.software === TRUTHSOCIAL,
v.software === MASTODON && gte(v.compatVersion, '2.4.3'),
v.software === TRUTHSOCIAL,
features.includes('v2_suggestions'),
]),
/** /**
* Supports V2 suggested accounts. * Set your birthday and view upcoming birthdays.
* @see GET /api/v2/suggestions * @see GET /api/v1/pleroma/birthdays
* @see POST /api/v1/accounts
* @see PATCH /api/v1/accounts/update_credentials
*/ */
suggestionsV2: any([ birthdays: v.software === PLEROMA && gte(v.version, '2.4.50'),
v.software === MASTODON && gte(v.compatVersion, '3.4.0'),
v.software === TRUTHSOCIAL,
features.includes('v2_suggestions'),
]),
/** Whether people who blocked you are visible through the API. */ /** Whether people who blocked you are visible through the API. */
blockersVisible: features.includes('blockers_visible'), blockersVisible: features.includes('blockers_visible'),
/** /**
* Can display trending hashtags. * Can bookmark statuses.
* @see GET /api/v1/trends * @see POST /api/v1/statuses/:id/bookmark
* @see GET /api/v1/bookmarks
*/ */
trends: any([ bookmarks: any([
v.software === MASTODON && gte(v.compatVersion, '3.0.0'), v.software === MASTODON && gte(v.compatVersion, '3.1.0'),
v.software === TRUTHSOCIAL, v.software === PLEROMA && gte(v.version, '0.9.9'),
v.software === PIXELFED,
]), ]),
/** /**
* Supports V2 media uploads. * Pleroma chats API.
* @see POST /api/v2/media * @see {@link https://docs.pleroma.social/backend/development/API/chats/}
*/ */
mediaV2: any([ chats: v.software === PLEROMA && gte(v.version, '2.1.0'),
v.software === MASTODON && gte(v.compatVersion, '3.1.3'),
// Even though Pleroma supports these endpoints, it has disadvantages
// v.software === PLEROMA && gte(v.version, '2.1.0'),
]),
/** /**
* Can display a timeline of all known public statuses. * Paginated chats API.
* Local and Fediverse timelines both use this feature. * @see GET /api/v2/chats
* @see GET /api/v1/timelines/public
*/ */
publicTimeline: any([ chatsV2: v.software === PLEROMA && gte(v.version, '2.3.0'),
v.software === MASTODON,
v.software === PLEROMA, /**
* Mastodon's newer solution for direct messaging.
* @see {@link https://docs.joinmastodon.org/methods/timelines/conversations/}
*/
conversations: any([
v.software === MASTODON && gte(v.compatVersion, '2.6.0'),
v.software === PLEROMA && gte(v.version, '0.9.9'),
v.software === PIXELFED,
]), ]),
// FIXME: long-term this shouldn't be a feature,
// but for now we want it to be overrideable in the build
darkMode: true,
/** /**
* Legacy DMs timeline where messages are displayed chronologically without groupings. * Legacy DMs timeline where messages are displayed chronologically without groupings.
* @see GET /api/v1/timelines/direct * @see GET /api/v1/timelines/direct
@ -177,14 +173,14 @@ const getInstanceFeatures = (instance: Instance) => {
]), ]),
/** /**
* Mastodon's newer solution for direct messaging. * Soapbox email list.
* @see {@link https://docs.joinmastodon.org/methods/timelines/conversations/} * @see POST /api/v1/accounts
* @see PATCH /api/v1/accounts/update_credentials
* @see GET /api/v1/pleroma/admin/email_list/subscribers.csv
* @see GET /api/v1/pleroma/admin/email_list/unsubscribers.csv
* @see GET /api/v1/pleroma/admin/email_list/combined.csv
*/ */
conversations: any([ emailList: features.includes('email_list'),
v.software === MASTODON && gte(v.compatVersion, '2.6.0'),
v.software === PLEROMA && gte(v.version, '0.9.9'),
v.software === PIXELFED,
]),
/** /**
* Ability to add emoji reactions to a status. * Ability to add emoji reactions to a status.
@ -201,126 +197,112 @@ const getInstanceFeatures = (instance: Instance) => {
emojiReactsRGI: v.software === PLEROMA && gte(v.version, '2.2.49'), emojiReactsRGI: v.software === PLEROMA && gte(v.version, '2.2.49'),
/** /**
* Allows setting the focal point of a media attachment. * Sign in with an Ethereum wallet.
* @see {@link https://docs.joinmastodon.org/methods/statuses/media/} * @see POST /oauth/token
*/ */
focalPoint: v.software === MASTODON && gte(v.compatVersion, '2.3.0'), ethereumLogin: v.software === MITRA,
/** /**
* Pleroma import API. * Ability to address recipients of a status explicitly (with `to`).
* @see POST /api/pleroma/follow_import * @see POST /api/v1/statuses
* @see POST /api/pleroma/blocks_import
* @see POST /api/pleroma/mutes_import
*/ */
importAPI: v.software === PLEROMA, explicitAddressing: any([
v.software === PLEROMA && gte(v.version, '1.0.0'),
v.software === TRUTHSOCIAL,
]),
/** /** Whether the accounts who favourited or emoji-reacted to a status can be viewed through the API. */
* Pleroma import mutes API. exposableReactions: features.includes('exposable_reactions'),
* @see POST /api/pleroma/mutes_import
*/
importMutes: v.software === PLEROMA && gte(v.version, '2.2.0'),
/** /** Whether the instance federates. */
* Soapbox email list. federating: federation.get('enabled', true) === true, // Assume true unless explicitly false
* @see POST /api/v1/accounts
* @see PATCH /api/v1/accounts/update_credentials
* @see GET /api/v1/pleroma/admin/email_list/subscribers.csv
* @see GET /api/v1/pleroma/admin/email_list/unsubscribers.csv
* @see GET /api/v1/pleroma/admin/email_list/combined.csv
*/
emailList: features.includes('email_list'),
/** /**
* Pleroma chats API. * Can edit and manage timeline filters (aka "muted words").
* @see {@link https://docs.pleroma.social/backend/development/API/chats/} * @see {@link https://docs.joinmastodon.org/methods/accounts/filters/}
*/ */
chats: v.software === PLEROMA && gte(v.version, '2.1.0'), filters: v.software !== TRUTHSOCIAL,
/** /**
* Paginated chats API. * Allows setting the focal point of a media attachment.
* @see GET /api/v2/chats * @see {@link https://docs.joinmastodon.org/methods/statuses/media/}
*/ */
chatsV2: v.software === PLEROMA && gte(v.version, '2.3.0'), focalPoint: v.software === MASTODON && gte(v.compatVersion, '2.3.0'),
/** /**
* List of OAuth scopes supported by both Soapbox and the backend. * Whether client settings can be retrieved from the API.
* @see POST /api/v1/apps * @see GET /api/pleroma/frontend_configurations
* @see POST /oauth/token
*/ */
scopes: v.software === PLEROMA ? 'read write follow push admin' : 'read write follow push', frontendConfigurations: v.software === PLEROMA,
/** Whether the instance federates. */
federating: federation.get('enabled', true) === true, // Assume true unless explicitly false
/** /**
* Ability to post statuses in Markdown, BBCode, and HTML. * Pleroma import API.
* @see POST /api/v1/statuses * @see POST /api/pleroma/follow_import
* @see POST /api/pleroma/blocks_import
* @see POST /api/pleroma/mutes_import
*/ */
richText: v.software === PLEROMA, importAPI: v.software === PLEROMA,
/** /**
* Ability to manage account security settings. * Pleroma import mutes API.
* @see POST /api/pleroma/change_password * @see POST /api/pleroma/mutes_import
* @see POST /api/pleroma/change_email
* @see POST /api/pleroma/delete_account
*/ */
securityAPI: any([ importMutes: v.software === PLEROMA && gte(v.version, '2.2.0'),
v.software === PLEROMA,
v.software === TRUTHSOCIAL,
]),
/** /**
* Can store client settings in the database. * Can create, view, and manage lists.
* @see PATCH /api/v1/accounts/update_credentials * @see {@link https://docs.joinmastodon.org/methods/timelines/lists/}
* @see GET /api/v1/timelines/list/:list_id
*/ */
settingsStore: any([ lists: any([
v.software === PLEROMA, v.software === MASTODON && gte(v.compatVersion, '2.1.0'),
v.software === TRUTHSOCIAL, v.software === PLEROMA && gte(v.version, '0.9.9'),
]), ]),
/** /**
* Can view and manage ActivityPub aliases through the API. * Can upload media attachments to statuses.
* @see GET /api/pleroma/aliases * @see POST /api/v1/media
* @see PATCH /api/v1/accounts/update_credentials * @see POST /api/v1/statuses
*/
accountAliasesAPI: v.software === PLEROMA,
/**
* Can request a password reset email through the API.
* @see POST /auth/password
*/ */
resetPasswordAPI: v.software === PLEROMA, media: true,
/** Whether the accounts who favourited or emoji-reacted to a status can be viewed through the API. */
exposableReactions: features.includes('exposable_reactions'),
/** /**
* Ability to subscribe to notifications every time an account posts. * Supports V2 media uploads.
* @see POST /api/v1/pleroma/accounts/:id/subscribe * @see POST /api/v2/media
* @see POST /api/v1/pleroma/accounts/:id/unsubscribe
*/ */
accountSubscriptions: v.software === PLEROMA && gte(v.version, '1.0.0'), mediaV2: any([
v.software === MASTODON && gte(v.compatVersion, '3.1.3'),
// Even though Pleroma supports these endpoints, it has disadvantages
// v.software === PLEROMA && gte(v.version, '2.1.0'),
]),
/** /**
* Ability to subscribe to notifications every time an account posts. * Add private notes to accounts.
* @see POST /api/v1/accounts/:id/follow * @see POST /api/v1/accounts/:id/note
* @see GET /api/v1/accounts/relationships
*/ */
accountNotifies: any([ notes: any([
v.software === MASTODON && gte(v.compatVersion, '3.3.0'), v.software === MASTODON && gte(v.compatVersion, '3.2.0'),
v.software === PLEROMA && gte(v.version, '2.4.50'), v.software === PLEROMA && gte(v.version, '2.4.50'),
]), ]),
/** Truth Social account registration API. */
pepe: v.software === TRUTHSOCIAL,
/** /**
* Whether the backend allows adding users you don't follow to lists. * Can add polls to statuses.
* @see POST /api/v1/lists/:id/accounts * @see POST /api/v1/statuses
*/ */
unrestrictedLists: v.software === PLEROMA, polls: any([
v.software === MASTODON && gte(v.version, '2.8.0'),
v.software === PLEROMA,
]),
/** /**
* The accounts API allows an acct instead of an ID. * Can set privacy scopes on statuses.
* @see GET /api/v1/accounts/:acct_or_id * @see POST /api/v1/statuses
*/ */
accountByUsername: v.software === PLEROMA, privacyScopes: v.software !== TRUTHSOCIAL,
/** /**
* A directory of discoverable profiles from the instance. * A directory of discoverable profiles from the instance.
@ -332,12 +314,22 @@ const getInstanceFeatures = (instance: Instance) => {
]), ]),
/** /**
* Look up an account by the acct. * Can display a timeline of all known public statuses.
* @see GET /api/v1/accounts/lookup * Local and Fediverse timelines both use this feature.
* @see GET /api/v1/timelines/public
*/ */
accountLookup: any([ publicTimeline: any([
v.software === MASTODON && gte(v.compatVersion, '3.4.0'), v.software === MASTODON,
v.software === PLEROMA,
]),
/**
* Ability to quote posts in statuses.
* @see POST /api/v1/statuses
*/
quotePosts: any([
v.software === PLEROMA && gte(v.version, '2.4.50'), v.software === PLEROMA && gte(v.version, '2.4.50'),
instance.feature_quote === true,
]), ]),
/** /**
@ -347,66 +339,79 @@ const getInstanceFeatures = (instance: Instance) => {
remoteInteractionsAPI: v.software === PLEROMA && gte(v.version, '2.4.50'), remoteInteractionsAPI: v.software === PLEROMA && gte(v.version, '2.4.50'),
/** /**
* Ability to address recipients of a status explicitly (with `to`). * Can request a password reset email through the API.
* @see POST /api/v1/statuses * @see POST /auth/password
*/ */
explicitAddressing: any([ resetPasswordAPI: v.software === PLEROMA,
v.software === PLEROMA && gte(v.version, '1.0.0'),
v.software === TRUTHSOCIAL,
]),
/** /**
* Ability to pin other accounts on one's profile. * Ability to post statuses in Markdown, BBCode, and HTML.
* @see POST /api/v1/accounts/:id/pin * @see POST /api/v1/statuses
* @see POST /api/v1/accounts/:id/unpin
* @see GET /api/v1/pleroma/accounts/:id/endorsements
*/ */
accountEndorsements: v.software === PLEROMA && gte(v.version, '2.4.50'), richText: v.software === PLEROMA,
/** /**
* Ability to quote posts in statuses. * Can schedule statuses to be posted at a later time.
* @see POST /api/v1/statuses * @see POST /api/v1/statuses
* @see {@link https://docs.joinmastodon.org/methods/statuses/scheduled_statuses/}
*/ */
quotePosts: any([ scheduledStatuses: any([
v.software === PLEROMA && gte(v.version, '2.4.50'), v.software === MASTODON && gte(v.version, '2.7.0'),
instance.feature_quote === true, v.software === PLEROMA,
]), ]),
/** /**
* Set your birthday and view upcoming birthdays. * List of OAuth scopes supported by both Soapbox and the backend.
* @see GET /api/v1/pleroma/birthdays * @see POST /api/v1/apps
* @see POST /api/v1/accounts * @see POST /oauth/token
* @see PATCH /api/v1/accounts/update_credentials
*/ */
birthdays: v.software === PLEROMA && gte(v.version, '2.4.50'), scopes: v.software === PLEROMA ? 'read write follow push admin' : 'read write follow push',
/** /**
* Sign in with an Ethereum wallet. * Ability to manage account security settings.
* @see POST /oauth/token * @see POST /api/pleroma/change_password
* @see POST /api/pleroma/change_email
* @see POST /api/pleroma/delete_account
*/ */
ethereumLogin: v.software === MITRA, securityAPI: any([
v.software === PLEROMA,
v.software === TRUTHSOCIAL,
]),
/** /**
* Move followers to a different ActivityPub account. * Can store client settings in the database.
* @see POST /api/pleroma/move_account * @see PATCH /api/v1/accounts/update_credentials
*/ */
accountMoving: v.software === PLEROMA && gte(v.version, '2.4.50'), settingsStore: any([
v.software === PLEROMA,
v.software === TRUTHSOCIAL,
]),
/** /**
* Add private notes to accounts. * Can set content warnings on statuses.
* @see POST /api/v1/accounts/:id/note * @see POST /api/v1/statuses
* @see GET /api/v1/accounts/relationships
*/ */
notes: any([ spoilers: v.software !== TRUTHSOCIAL,
v.software === MASTODON && gte(v.compatVersion, '3.2.0'),
v.software === PLEROMA && gte(v.version, '2.4.50'), /**
* Can display suggested accounts.
* @see {@link https://docs.joinmastodon.org/methods/accounts/suggestions/}
*/
suggestions: any([
v.software === MASTODON && gte(v.compatVersion, '2.4.3'),
v.software === TRUTHSOCIAL,
features.includes('v2_suggestions'),
]), ]),
/** /**
* Truth Social trending statuses API. * Supports V2 suggested accounts.
* @see GET /api/v1/truth/trending/truths * @see GET /api/v2/suggestions
*/ */
trendingTruths: v.software === TRUTHSOCIAL, suggestionsV2: any([
v.software === MASTODON && gte(v.compatVersion, '3.4.0'),
v.software === TRUTHSOCIAL,
features.includes('v2_suggestions'),
]),
/** /**
* Trending statuses. * Trending statuses.
@ -414,30 +419,26 @@ const getInstanceFeatures = (instance: Instance) => {
*/ */
trendingStatuses: v.software === MASTODON && gte(v.compatVersion, '3.5.0'), trendingStatuses: v.software === MASTODON && gte(v.compatVersion, '3.5.0'),
/** Truth Social account registration API. */
pepe: v.software === TRUTHSOCIAL,
/** /**
* Ability to set one's location on their profile. * Truth Social trending statuses API.
* @see PATCH /api/v1/accounts/update_credentials * @see GET /api/v1/truth/trending/truths
*/ */
accountLocation: v.software === TRUTHSOCIAL, trendingTruths: v.software === TRUTHSOCIAL,
/** /**
* Ability to set one's website on their profile. * Can display trending hashtags.
* @see PATCH /api/v1/accounts/update_credentials * @see GET /api/v1/trends
*/ */
accountWebsite: v.software === TRUTHSOCIAL, trends: any([
v.software === MASTODON && gte(v.compatVersion, '3.0.0'),
v.software === TRUTHSOCIAL,
]),
/** /**
* Whether client settings can be retrieved from the API. * Whether the backend allows adding users you don't follow to lists.
* @see GET /api/pleroma/frontend_configurations * @see POST /api/v1/lists/:id/accounts
*/ */
frontendConfigurations: v.software === PLEROMA, unrestrictedLists: v.software === PLEROMA,
// FIXME: long-term this shouldn't be a feature,
// but for now we want it to be overrideable in the build
darkMode: true,
}; };
}; };
@ -469,17 +470,17 @@ export const parseVersion = (version: string): Backend => {
if (match) { if (match) {
return { return {
compatVersion: match[1],
software: match[2] || MASTODON, software: match[2] || MASTODON,
version: match[3] || match[1], version: match[3] || match[1],
compatVersion: match[1],
}; };
} else { } else {
// If we can't parse the version, this is a new and exotic backend. // If we can't parse the version, this is a new and exotic backend.
// Fall back to minimal featureset. // Fall back to minimal featureset.
return { return {
compatVersion: '0.0.0',
software: null, software: null,
version: '0.0.0', version: '0.0.0',
compatVersion: '0.0.0',
}; };
} }
}; };

Loading…
Cancel
Save