mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
52 lines
970 B
TypeScript
52 lines
970 B
TypeScript
import { z } from "zod";
|
|
|
|
const MessageEntitySchema = z.object({
|
|
$id: z.any().optional(),
|
|
id: z.string().optional(),
|
|
roomId: z.string().uuid(),
|
|
message: z.string(),
|
|
messageType: z.number(),
|
|
canEdit: z.boolean(),
|
|
oneShot: z.boolean(),
|
|
sentAt: z.string().optional(),
|
|
requireUnlock: z.boolean(),
|
|
sender: z.object({
|
|
wxUserId: z.number(),
|
|
wxFullName: z.string(),
|
|
wxeMail: z.string(),
|
|
userPhoto: z.string(),
|
|
}),
|
|
sending: z.boolean().optional()
|
|
})
|
|
|
|
type Message = z.infer<typeof MessageEntitySchema>;
|
|
|
|
export class MessageEntity implements Message {
|
|
|
|
$id: number
|
|
id: string
|
|
roomId: string
|
|
message: string
|
|
messageType: number
|
|
canEdit: boolean
|
|
oneShot: boolean
|
|
sentAt: string
|
|
requireUnlock: boolean
|
|
sender: {
|
|
wxUserId: number,
|
|
wxFullName: string,
|
|
wxeMail: string,
|
|
userPhoto: string,
|
|
}
|
|
sending: boolean
|
|
|
|
constructor() {}
|
|
|
|
get messageStatus() {
|
|
if(this.id) {
|
|
return 'send'
|
|
}
|
|
}
|
|
|
|
}
|