bigbuffet-rw/src/schemas/chat-message.ts
marcin mikołajczak 0308aec65b Remove Truth Social-specific features
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-04-28 14:50:23 +02:00

24 lines
No EOL
761 B
TypeScript

import { z } from 'zod';
import { attachmentSchema } from './attachment';
import { cardSchema } from './card';
import { customEmojiSchema } from './custom-emoji';
import { contentSchema, filteredArray } from './utils';
const chatMessageSchema = z.object({
account_id: z.string(),
media_attachments: filteredArray(attachmentSchema),
card: cardSchema.nullable().catch(null),
chat_id: z.string(),
content: contentSchema,
created_at: z.string().datetime().catch(new Date().toUTCString()),
emojis: filteredArray(customEmojiSchema),
id: z.string(),
unread: z.coerce.boolean(),
deleting: z.coerce.boolean(),
pending: z.coerce.boolean(),
});
type ChatMessage = z.infer<typeof chatMessageSchema>;
export { chatMessageSchema, type ChatMessage };