Display emoji reactions on glitch-soc and Iceshrimp

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2023-10-29 23:00:48 +01:00
parent 3000ed6f9d
commit 1d3424e648
12 changed files with 103 additions and 129 deletions

View File

@@ -49,6 +49,9 @@ const configurationSchema = coerceObject({
max_options: z.number().optional().catch(undefined),
min_expiration: z.number().optional().catch(undefined),
}),
reactions: coerceObject({
max_reactions: z.number().catch(0),
}),
statuses: coerceObject({
max_characters: z.number().optional().catch(undefined),
max_media_attachments: z.number().optional().catch(undefined),

View File

@@ -19,7 +19,6 @@ import { contentSchema, dateSchema, filteredArray, makeCustomEmojiMap } from './
import type { Resolve } from 'soapbox/utils/types';
const statusPleromaSchema = z.object({
emoji_reactions: filteredArray(emojiReactionSchema),
event: eventSchema.nullish().catch(undefined),
quote: z.literal(null).catch(null),
quote_visible: z.boolean().catch(true),
@@ -51,6 +50,7 @@ const baseStatusSchema = z.object({
muted: z.coerce.boolean(),
pinned: z.coerce.boolean(),
pleroma: statusPleromaSchema.optional().catch(undefined),
reactions: filteredArray(emojiReactionSchema),
poll: pollSchema.nullable().catch(null),
quote: z.literal(null).catch(null),
quotes_count: z.number().catch(0),
@@ -131,16 +131,18 @@ const statusSchema = baseStatusSchema.extend({
reblog: embeddedStatusSchema,
pleroma: statusPleromaSchema.extend({
quote: embeddedStatusSchema,
emoji_reactions: filteredArray(emojiReactionSchema),
}).optional().catch(undefined),
}).transform(({ pleroma, ...status }) => {
return {
...status,
event: pleroma?.event,
quote: pleroma?.quote || status.quote || null,
reactions: pleroma?.emoji_reactions || status.reactions || null,
// There's apparently no better way to do this...
// Just trying to remove the `event` and `quote` keys from the object.
pleroma: pleroma ? (() => {
const { event, quote, ...rest } = pleroma;
const { event, quote, emoji_reactions, ...rest } = pleroma;
return rest;
})() : undefined,
};