bigbuffet-rw/packages/pl-api/lib/entities/chat-message.ts
marcin mikołajczak 036fa32cd3 Add pl-api to workspace
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-08-28 13:43:23 +02:00

23 lines
803 B
TypeScript

import { z } from 'zod';
import { customEmojiSchema } from './custom-emoji';
import { mediaAttachmentSchema } from './media-attachment';
import { previewCardSchema } from './preview-card';
import { dateSchema, filteredArray } from './utils';
/** @see {@link https://docs.pleroma.social/backend/development/API/chats/#getting-the-messages-for-a-chat} */
const chatMessageSchema = z.object({
id: z.string(),
content: z.string().catch(''),
chat_id: z.string(),
account_id: z.string(),
created_at: dateSchema,
emojis: filteredArray(customEmojiSchema),
attachment: mediaAttachmentSchema.nullable().catch(null),
unread: z.boolean(),
card: previewCardSchema.nullable().catch(null),
});
type ChatMessage = z.infer<typeof chatMessageSchema>;
export { chatMessageSchema, type ChatMessage };