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

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2023-05-07 22:54:04 +02:00
217 changed files with 1435 additions and 1230 deletions

View File

@ -1,4 +1,4 @@
import { normalizeAd } from 'soapbox/normalizers';
import { buildAd } from 'soapbox/jest/factory';
import { isExpired } from '../ads';
@ -14,10 +14,10 @@ test('isExpired()', () => {
const epoch = now.getTime();
// Sanity tests.
expect(isExpired(normalizeAd({ expires_at: iso }))).toBe(true);
expect(isExpired(normalizeAd({ expires_at: new Date(epoch + 999999).toISOString() }))).toBe(false);
expect(isExpired(buildAd({ expires_at: iso }))).toBe(true);
expect(isExpired(buildAd({ expires_at: new Date(epoch + 999999).toISOString() }))).toBe(false);
// Testing the 5-minute mark.
expect(isExpired(normalizeAd({ expires_at: new Date(epoch + threeMins).toISOString() }), fiveMins)).toBe(true);
expect(isExpired(normalizeAd({ expires_at: new Date(epoch + fiveMins + 1000).toISOString() }), fiveMins)).toBe(false);
expect(isExpired(buildAd({ expires_at: new Date(epoch + threeMins).toISOString() }), fiveMins)).toBe(true);
expect(isExpired(buildAd({ expires_at: new Date(epoch + fiveMins + 1000).toISOString() }), fiveMins)).toBe(false);
});

View File

@ -1,4 +1,4 @@
import type { Ad } from 'soapbox/types/soapbox';
import type { Ad } from 'soapbox/schemas';
/** Time (ms) window to not display an ad if it's about to expire. */
const AD_EXPIRY_THRESHOLD = 5 * 60 * 1000;

View File

@ -16,6 +16,12 @@ const overrides = custom('features');
/** Truthy array convenience function */
const any = (arr: Array<any>): boolean => arr.some(Boolean);
/**
* Ditto, a Nostr server with Mastodon API.
* @see {@link https://gitlab.com/soapbox-pub/ditto}
*/
export const DITTO = 'Ditto';
/**
* Friendica, decentralized social platform implementing multiple federation protocols.
* @see {@link https://friendi.ca/}
@ -137,6 +143,7 @@ const getInstanceFeatures = (instance: Instance) => {
v.software === PLEROMA && gte(v.version, '2.4.50'),
v.software === TAKAHE && gte(v.version, '0.6.1'),
v.software === TRUTHSOCIAL,
v.software === DITTO,
]),
/**
@ -254,7 +261,7 @@ const getInstanceFeatures = (instance: Instance) => {
/**
* Ability to add reactions to chat messages.
*/
chatEmojiReactions: v.software === TRUTHSOCIAL && v.build === UNRELEASED,
chatEmojiReactions: v.software === TRUTHSOCIAL,
/**
* Pleroma chats API.