bigbuffet-rw/packages/pl-api/lib/entities/chat-message.ts
marcin mikołajczak a521c9044d make pl-api compile
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-10-16 17:03:27 +02:00

23 lines
842 B
TypeScript

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