bigbuffet-rw/packages/pl-api/lib/entities/chat-message.ts
marcin mikołajczak a6bc160caa pl-api: Do some blind search and replace
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-10-14 00:25:30 +02:00

23 lines
834 B
TypeScript

import * as v from 'valibot';
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 = v.object({
id: v.string(),
content: v.fallback(v.string(), ''),
chat_id: v.string(),
account_id: v.string(),
created_at: dateSchema,
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 };