mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
fix chat
This commit is contained in:
@@ -37,34 +37,28 @@ export class MessageCreateUseCaseService {
|
||||
const createMessageLocally = await this.MessageRepositoryService.createMessageLocally(message)
|
||||
|
||||
if(createMessageLocally.isOk()) {
|
||||
|
||||
|
||||
console.log('==========================',message);
|
||||
if(message.hasAttachment) {
|
||||
|
||||
|
||||
for (const attachment of message.attachments) {
|
||||
|
||||
|
||||
const createAttachmentLocally = this.AttachmentRepositoryService.create({
|
||||
$messageId: createMessageLocally.value.$id,
|
||||
file: createDataURL(attachment.file, attachment.mimeType)
|
||||
file: createDataURL(attachment.file, attachment.mimeType)
|
||||
})
|
||||
|
||||
attachment.safeFile = createDataURL(attachment.file, attachment.mimeType)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
const sendToServer = await this.MessageRepositoryService.sendMessage(message)
|
||||
|
||||
|
||||
// if(sendToServer.isOk()) {
|
||||
// for (const attachment of message.attachments) {
|
||||
|
||||
// const attachment = await this.AttachmentRepositoryService.findOne({
|
||||
// $messageId: createMessageLocally.value.$id
|
||||
// })
|
||||
// }
|
||||
|
||||
// }
|
||||
if(!sendToServer.isOk()) {
|
||||
console.log('sendToServer error', sendToServer.error)
|
||||
}
|
||||
|
||||
|
||||
return sendToServer
|
||||
|
||||
@@ -7,7 +7,7 @@ const MessageUpdateInputDTOSchema = z.object({
|
||||
memberId: z.number(),
|
||||
messageId: z.string(),
|
||||
roomId: z.string(),
|
||||
message: z.string(),
|
||||
message: z.string().optional().nullable(),
|
||||
requestId: z.string().optional()
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { RoomRepositoryService } from 'src/app/module/chat/data/repository/room-repository.service'
|
||||
import { MessageRepositoryService } from 'src/app/module/chat/data/repository/message-respository.service'
|
||||
import { RoomTable } from '../../infra/database/dexie/schema/room';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SyncAllRoomMessagesService {
|
||||
|
||||
constructor(
|
||||
private RoomRepositoryService: RoomRepositoryService,
|
||||
private MessageRepositoryService: MessageRepositoryService
|
||||
) { }
|
||||
|
||||
async execute() {
|
||||
|
||||
const allRooms: RoomTable[] = await this.RoomRepositoryService.getRoomList()
|
||||
|
||||
if(allRooms) {
|
||||
for(const room of allRooms) {
|
||||
this.MessageRepositoryService.listAllMessagesByRoomId(room.id)
|
||||
}
|
||||
} else {
|
||||
console.log('get all error', allRooms)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user