add audio

This commit is contained in:
Peter Maquiran
2024-08-15 16:34:07 +01:00
parent 8e25733760
commit d1918d6695
10 changed files with 48 additions and 43 deletions
@@ -1,5 +1,6 @@
import { z } from "zod";
import { MessageAttachmentFileType, MessageAttachmentSource } from "./messageOutputDTO";
import { base64Schema } from "src/app/utils/zod";
export const MessageInputDTOSchema = z.object({
roomId: z.string().uuid(),
@@ -13,10 +14,10 @@ export const MessageInputDTOSchema = z.object({
attachment: z.object({
fileType: z.nativeEnum(MessageAttachmentFileType),
source: z.nativeEnum(MessageAttachmentSource),
file: z.string(),
fileName: z.string(),
applicationId: z.string(),
docId: z.string(),
file: base64Schema.optional(),
fileName: z.string().optional(),
applicationId: z.string().optional(),
docId: z.string().optional(),
mimeType: z.string().optional()
}).optional()
});
@@ -42,7 +42,7 @@ export const MessageOutPutDataDTOSchema = z.object({
fileName: z.string().optional(),
applicationId: z.string().optional(),
docId: z.string().optional(),
id: z.string()
id: z.string().optional()
}))
});
@@ -227,11 +227,11 @@ export class RoomRepositoryService {
@captureAndReraiseAsync('RoomRepositoryService/addMemberToRoom')
async addMemberToRoom(data: AddMemberToRoomInputDTO) {
//return this.roomLiveSignalRDataSourceService.addMemberToRoom(data)
return this.roomLiveSignalRDataSourceService.addMemberToRoom(data)
const result = await this.roomRemoteDataSourceService.addMemberToRoom(data)
// const result = await this.roomRemoteDataSourceService.addMemberToRoom(data)
return result
// return result
}
async updateMemberStatus(data: MemberListUPdateStatusInputDTO) {
+4 -2
View File
@@ -26,8 +26,10 @@ export const MessageEntitySchema = z.object({
file: base64Schema.optional(),
fileName: z.string().optional(),
applicationId: z.string().optional(),
docId: z.string().optional()
})),
docId: z.string().optional(),
id: z.string().optional(),
mimeType: z.string().optional()
})).optional()
})
type Message = z.infer<typeof MessageEntitySchema>;
@@ -9,7 +9,7 @@ export class MessageMapper {
}
static fromDomain(entity:MessageEntity, requestId): MessageInputDTO {
return{
return {
canEdit: entity.canEdit,
message: entity.message,
messageType: entity.messageType,
@@ -18,7 +18,16 @@ export class MessageMapper {
roomId: entity.roomId,
senderId: entity.sender.wxUserId,
requestId: requestId,
attachment: entity.attachments[0]
attachment: entity.attachments.map((e)=>({
fileType:e.fileType,
source: e.source,
file: e.file,
fileName: e.fileName,
applicationId: e.applicationId,
docId: e.docId,
mimeType: e.mimeType
}))[0]
}
}
}
@@ -47,9 +47,13 @@ export class MessageCreateUseCaseService {
for (const attachment of message.attachments) {
const createAttachmentLocally = this.AttachmentRepositoryService.create({
this.AttachmentRepositoryService.create({
$messageId: createMessageLocally.value.$id,
file: createDataURL(attachment.file, attachment.mimeType)
}).then((e) => {
if(e.isErr()) {
console.log('e', e.error, createDataURL(attachment.file, attachment.mimeType))
}
})
attachment.safeFile = createDataURL(attachment.file, attachment.mimeType)
@@ -31,7 +31,9 @@ export const MessageTableSchema = z.object({
source: z.nativeEnum(MessageAttachmentSource),
fileName: z.string().optional(),
applicationId: z.string().optional(),
docId: z.string().optional()
docId: z.string().optional(),
id: z.string().optional(),
mimeType: z.string().optional()
})).optional()
})