Files
doneit-web/src/app/module/chat/domain/entity/message.ts
T

71 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-08-06 12:01:59 +01:00
import { z } from "zod";
2024-08-09 10:50:32 +01:00
import { MessageAttachmentFileType, MessageAttachmentSource } from "../../data/dto/message/messageOutputDTO";
2024-08-06 12:01:59 +01:00
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(),
}),
2024-08-09 10:50:32 +01:00
sending: z.boolean().optional(),
attachments: z.array(z.object({
fileType: z.nativeEnum(MessageAttachmentFileType),
source: z.nativeEnum(MessageAttachmentSource),
file: z.string(),
fileName: z.string(),
applicationId: z.string(),
docId: z.string()
}))
2024-08-06 12:01:59 +01:00
})
type Message = z.infer<typeof MessageEntitySchema>;
export class MessageEntity implements Message {
$id: number
id: string
roomId: string
message: string
messageType: number = 0
canEdit: boolean = false
oneShot: boolean = false
2024-08-06 12:01:59 +01:00
sentAt: string
requireUnlock: boolean = false
2024-08-06 12:01:59 +01:00
sender: {
wxUserId: number,
wxFullName: string,
wxeMail: string,
userPhoto: string,
}
sending: boolean = false
2024-08-06 16:53:13 +01:00
sendAttemp = 0
2024-08-06 12:01:59 +01:00
2024-08-09 10:50:32 +01:00
attachments: {
fileType: MessageAttachmentFileType,
source: MessageAttachmentSource,
2024-08-09 12:36:51 +01:00
file?: string,
2024-08-09 10:50:32 +01:00
fileName: string,
applicationId?: string,
docId?: string
}[]
2024-08-06 12:01:59 +01:00
constructor() {}
get messageStatus() {
if(this.id) {
return 'send'
}
}
}