diff --git a/app/soapbox/schemas/chat-message.ts b/app/soapbox/schemas/chat-message.ts index a64ffec0b..121ef9d5f 100644 --- a/app/soapbox/schemas/chat-message.ts +++ b/app/soapbox/schemas/chat-message.ts @@ -1,9 +1,25 @@ import { z } from 'zod'; -import { normalizeChatMessage } from 'soapbox/normalizers'; -import { toSchema } from 'soapbox/utils/normalizers'; +import { attachmentSchema } from './attachment'; +import { cardSchema } from './card'; +import { customEmojiSchema } from './custom-emoji'; +import { emojiSchema, filteredArray } from './utils'; -const chatMessageSchema = toSchema(normalizeChatMessage); +const chatMessageSchema = z.object({ + account_id: z.string(), + media_attachments: filteredArray(attachmentSchema), + card: cardSchema.nullable().catch(null), + chat_id: z.string(), + content: z.string().catch(''), + created_at: z.string().datetime().catch(new Date().toUTCString()), + emojis: filteredArray(customEmojiSchema), + expiration: z.number().optional().catch(undefined), + emoji_reactions: z.array(emojiSchema).min(1).nullable().catch(null), + id: z.string(), + unread: z.coerce.boolean(), + deleting: z.coerce.boolean(), + pending: z.coerce.boolean(), +}); type ChatMessage = z.infer; diff --git a/app/soapbox/schemas/tag.ts b/app/soapbox/schemas/tag.ts index 5f74a31c7..22e903d60 100644 --- a/app/soapbox/schemas/tag.ts +++ b/app/soapbox/schemas/tag.ts @@ -5,7 +5,7 @@ const historySchema = z.object({ uses: z.coerce.number(), }); -/** // https://docs.joinmastodon.org/entities/tag */ +/** https://docs.joinmastodon.org/entities/tag */ const tagSchema = z.object({ name: z.string().min(1), url: z.string().url().catch(''),