diff --git a/app/soapbox/schemas/account.ts b/app/soapbox/schemas/account.ts index 919013329..f2e5f9c15 100644 --- a/app/soapbox/schemas/account.ts +++ b/app/soapbox/schemas/account.ts @@ -49,7 +49,7 @@ const accountSchema = z.object({ verified: z.boolean().default(false), website: z.string().catch(''), - /** + /* * Internal fields */ display_name_html: z.string().catch(''), @@ -57,7 +57,7 @@ const accountSchema = z.object({ note_emojified: z.string().catch(''), relationship: relationshipSchema.nullable().catch(null), - /** + /* * Misc */ other_settings: z.any(), @@ -99,7 +99,7 @@ const accountSchema = z.object({ // Notes account.note_emojified = emojify(account.note, customEmojiMap); - /** + /* * Todo * - internal fields * - donor diff --git a/app/soapbox/schemas/attachment.ts b/app/soapbox/schemas/attachment.ts index 44b9cb126..3df39d542 100644 --- a/app/soapbox/schemas/attachment.ts +++ b/app/soapbox/schemas/attachment.ts @@ -62,6 +62,12 @@ const audioAttachmentSchema = baseAttachmentSchema.extend({ type: z.literal('audio'), meta: z.object({ duration: z.number().optional().catch(undefined), + colors: z.object({ + background: z.string().optional().catch(undefined), + foreground: z.string().optional().catch(undefined), + accent: z.string().optional().catch(undefined), + duration: z.number().optional().catch(undefined), + }).optional().catch(undefined), }).catch({}), }); diff --git a/app/soapbox/schemas/status.ts b/app/soapbox/schemas/status.ts index edb585aec..323ca5789 100644 --- a/app/soapbox/schemas/status.ts +++ b/app/soapbox/schemas/status.ts @@ -40,6 +40,9 @@ const baseStatusSchema = z.object({ mentions: filteredArray(mentionSchema), muted: z.coerce.boolean(), pinned: z.coerce.boolean(), + pleroma: z.object({ + quote_visible: z.boolean().catch(true), + }).optional().catch(undefined), poll: pollSchema.nullable().catch(null), quote: z.literal(null).catch(null), quotes_count: z.number().catch(0), @@ -58,7 +61,7 @@ const baseStatusSchema = z.object({ }); type BaseStatus = z.infer; -type TransformableStatus = Omit; +type TransformableStatus = Omit; /** Creates search index from the status. */ const buildSearchIndex = (status: TransformableStatus): string => { @@ -76,6 +79,11 @@ const buildSearchIndex = (status: TransformableStatus): string => { return new DOMParser().parseFromString(searchContent, 'text/html').documentElement.textContent || ''; }; +type Translation = { + content: string + provider: string +} + /** Add internal fields to the status. */ const transformStatus = (status: T) => { const emojiMap = makeCustomEmojiMap(status.emojis); @@ -89,6 +97,11 @@ const transformStatus = (status: T) => { spoilerHtml, search_index: buildSearchIndex(status), hidden: false, + filtered: [], + showFiltered: false, // TODO: this should be removed from the schema and done somewhere else + approval_status: 'approval' as const, + translation: undefined as Translation | undefined, + expectsCard: false, }; }; @@ -103,12 +116,19 @@ const statusSchema = baseStatusSchema.extend({ pleroma: z.object({ event: eventSchema, quote: embeddedStatusSchema, - }), + quote_visible: z.boolean().catch(true), + }).optional().catch(undefined), }).transform(({ pleroma, ...status }) => { return { ...status, - event: pleroma.event, - quote: pleroma.quote || status.quote, + event: pleroma?.event, + quote: pleroma?.quote || status.quote || 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; + return rest; + })() : undefined, }; }).transform(transformStatus);