2024-10-13 15:25:30 -07:00
|
|
|
import * as v from 'valibot';
|
2024-08-28 04:43:23 -07:00
|
|
|
|
|
|
|
import { accountSchema } from './account';
|
|
|
|
import { chatMessageSchema } from './chat-message';
|
2024-10-16 08:03:27 -07:00
|
|
|
import { datetimeSchema } from './utils';
|
2024-08-28 04:43:23 -07:00
|
|
|
|
|
|
|
/** @see {@link https://docs.pleroma.social/backend/development/API/chats/#getting-a-list-of-chats} */
|
2024-10-13 15:25:30 -07:00
|
|
|
const chatSchema = v.object({
|
|
|
|
id: v.string(),
|
2024-08-28 04:43:23 -07:00
|
|
|
account: accountSchema,
|
2024-10-14 11:54:44 -07:00
|
|
|
unread: v.pipe(v.number(), v.integer()),
|
2024-10-13 15:25:30 -07:00
|
|
|
last_message: v.fallback(v.nullable(chatMessageSchema), null),
|
2024-10-16 08:03:27 -07:00
|
|
|
updated_at: datetimeSchema,
|
2024-08-28 04:43:23 -07:00
|
|
|
});
|
|
|
|
|
2024-10-13 15:25:30 -07:00
|
|
|
type Chat = v.InferOutput<typeof chatSchema>;
|
2024-08-28 04:43:23 -07:00
|
|
|
|
|
|
|
export { chatSchema, type Chat };
|