mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
soft delete
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
import { z } from "zod";
|
||||
import { MessageAttachmentFileType, MessageAttachmentSource } from "../../../module/chat/data/dto/message/messageOutputDTO";
|
||||
import { SafeResourceUrl } from "@angular/platform-browser";
|
||||
import { base64Schema } from "src/app/utils/zod";
|
||||
|
||||
export const MessageEntitySchema = z.object({
|
||||
$id: z.any().optional(),
|
||||
id: z.string().optional(),
|
||||
roomId: z.string().uuid().optional(),
|
||||
receiverId: z.number().optional(),
|
||||
message: z.string().optional(),
|
||||
messageType: z.number(),
|
||||
canEdit: z.boolean(),
|
||||
oneShot: z.boolean(),
|
||||
sentAt: z.string().optional(),
|
||||
requireUnlock: z.boolean(),
|
||||
editedAt: z.string().nullable().optional(),
|
||||
sender: z.object({
|
||||
wxUserId: z.number(),
|
||||
wxFullName: z.string(),
|
||||
wxeMail: z.string(),
|
||||
userPhoto: z.string(),
|
||||
}),
|
||||
info: z.array(z.object({
|
||||
memberId: z.number(),
|
||||
readAt: z.string().nullable(),
|
||||
deliverAt: z.string().nullable()
|
||||
})).optional(),
|
||||
sending: z.boolean().optional(),
|
||||
attachments: z.array(z.object({
|
||||
fileType: z.nativeEnum(MessageAttachmentFileType),
|
||||
source: z.nativeEnum(MessageAttachmentSource),
|
||||
file: base64Schema.optional(),
|
||||
fileName: z.string().optional(),
|
||||
applicationId: z.number().optional(),
|
||||
docId: z.string().optional(),
|
||||
id: z.string().optional(),
|
||||
mimeType: z.string().optional()
|
||||
})).optional()
|
||||
})
|
||||
|
||||
type Message = z.infer<typeof MessageEntitySchema>;
|
||||
|
||||
export class MessageEntity {
|
||||
|
||||
$id?: number
|
||||
id?: string
|
||||
roomId?: string
|
||||
receiverId?: number
|
||||
message?: string
|
||||
messageType: number = 0
|
||||
canEdit: boolean = false
|
||||
oneShot: boolean = false
|
||||
sentAt?: string
|
||||
requireUnlock: boolean = false
|
||||
info: {
|
||||
memberId?: number
|
||||
readAt?: string,
|
||||
deliverAt?: string
|
||||
}[] = []
|
||||
sender!: {
|
||||
wxUserId: number,
|
||||
wxFullName: string,
|
||||
wxeMail: string,
|
||||
userPhoto: string,
|
||||
}
|
||||
sending: boolean = false
|
||||
sendAttemp = 0
|
||||
|
||||
attachments: {
|
||||
safeFile?: SafeResourceUrl;
|
||||
fileType: MessageAttachmentFileType,
|
||||
source: MessageAttachmentSource,
|
||||
file?: string,
|
||||
fileName: string,
|
||||
applicationId?: number,
|
||||
docId?: string,
|
||||
mimeType?: string,
|
||||
description?: string
|
||||
id?: string
|
||||
}[] = []
|
||||
|
||||
reactions = []
|
||||
|
||||
requestId!: string
|
||||
|
||||
constructor() {}
|
||||
|
||||
get messageStatus() {
|
||||
if(this.id) {
|
||||
return 'send'
|
||||
}
|
||||
}
|
||||
|
||||
get hasAttachment() {
|
||||
return this.attachments.length >= 1
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user