Merge remote-tracking branch 'soapbox/develop' into lexical

This commit is contained in:
marcin mikołajczak
2023-07-17 23:42:50 +02:00
96 changed files with 491 additions and 665 deletions

View File

@@ -34,9 +34,10 @@ export const isLocal = (account: Pick<Account, 'acct'>): boolean => {
export const isRemote = (account: Pick<Account, 'acct'>): boolean => !isLocal(account);
/** Default header filenames from various backends */
const DEFAULT_HEADERS = [
const DEFAULT_HEADERS: string[] = [
'/headers/original/missing.png', // Mastodon
'/images/banner.png', // Pleroma
require('assets/images/header-missing.png'), // header not provided by backend
];
/** Check if the avatar is a default avatar */
@@ -48,6 +49,7 @@ export const isDefaultHeader = (url: string) => {
const DEFAULT_AVATARS = [
'/avatars/original/missing.png', // Mastodon
'/images/avi.png', // Pleroma
require('assets/images/avatar-missing.png'), // avatar not provided by backend
];
/** Check if the avatar is a default avatar */

View File

@@ -16,6 +16,12 @@ const overrides = custom('features');
/** Truthy array convenience function */
const any = (arr: Array<any>): boolean => arr.some(Boolean);
/**
* Calckey, a fork of Misskey.
* @see {@link https://calckey.org/}
*/
export const CALCKEY = 'Calckey';
/**
* Ditto, a Nostr server with Mastodon API.
* @see {@link https://gitlab.com/soapbox-pub/ditto}
@@ -139,6 +145,7 @@ const getInstanceFeatures = (instance: Instance) => {
* @see GET /api/v1/accounts/lookup
*/
accountLookup: any([
v.software === CALCKEY,
v.software === MASTODON && gte(v.compatVersion, '3.4.0'),
v.software === PLEROMA && gte(v.version, '2.4.50'),
v.software === TAKAHE && gte(v.version, '0.6.1'),
@@ -224,6 +231,7 @@ const getInstanceFeatures = (instance: Instance) => {
* @see GET /api/v1/bookmarks
*/
bookmarks: any([
v.software === CALCKEY,
v.software === FRIENDICA,
v.software === MASTODON && gte(v.compatVersion, '3.1.0'),
v.software === PLEROMA && gte(v.version, '0.9.9'),
@@ -324,6 +332,7 @@ const getInstanceFeatures = (instance: Instance) => {
* @see {@link https://docs.joinmastodon.org/methods/conversations/}
*/
conversations: any([
v.software === CALCKEY,
v.software === FRIENDICA,
v.software === MASTODON && gte(v.compatVersion, '2.6.0'),
v.software === PLEROMA && gte(v.version, '0.9.9'),
@@ -362,6 +371,7 @@ const getInstanceFeatures = (instance: Instance) => {
* @see PATCH /api/v1/accounts/update_credentials
*/
editProfile: any([
v.software === CALCKEY,
v.software === FRIENDICA,
v.software === MASTODON,
v.software === MITRA,
@@ -447,6 +457,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 === CALCKEY,
v.software === FRIENDICA,
v.software === MASTODON,
v.software === TAKAHE && gte(v.version, '0.6.1'),
@@ -460,6 +471,7 @@ const getInstanceFeatures = (instance: Instance) => {
*/
familiarFollowers: any([
v.software === MASTODON && gte(v.version, '3.5.0'),
v.software === PLEROMA && gte(v.version, '2.5.51') && v.build === REBASED,
v.software === TAKAHE,
]),
@@ -625,6 +637,7 @@ const getInstanceFeatures = (instance: Instance) => {
* @see GET /api/v1/timelines/list/:list_id
*/
lists: any([
v.software === CALCKEY,
v.software === FRIENDICA,
v.software === MASTODON && gte(v.compatVersion, '2.1.0'),
v.software === PLEROMA && gte(v.version, '0.9.9'),
@@ -737,6 +750,7 @@ const getInstanceFeatures = (instance: Instance) => {
* @see POST /api/v1/statuses
*/
polls: any([
v.software === CALCKEY,
v.software === MASTODON && gte(v.version, '2.8.0'),
v.software === PLEROMA,
v.software === TRUTHSOCIAL,
@@ -773,6 +787,7 @@ const getInstanceFeatures = (instance: Instance) => {
* @see GET /api/v1/timelines/public
*/
publicTimeline: any([
v.software === CALCKEY,
v.software === FRIENDICA,
v.software === MASTODON,
v.software === PLEROMA,

View File

@@ -26,4 +26,13 @@ export type Normalizer<V, R> = (value: V) => R;
*/
export const toSchema = <V, R>(normalizer: Normalizer<V, R>) => {
return z.custom<V>().transform<R>(normalizer);
};
/** Legacy normalizer transition helper function. */
export const maybeFromJS = (value: any): unknown => {
if ('toJS' in value) {
return value.toJS();
} else {
return value;
}
};