mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
fix chat
This commit is contained in:
@@ -13,6 +13,7 @@ import { ListenMessageByRoomIdNewUseCase } from 'src/app/module/chat/domain/use-
|
||||
import { MemberListUpdateStatusUseCaseService } from 'src/app/module/chat/domain/use-case/socket/member-list-update-status-use-case.service';
|
||||
import { ListenMessageDeleteByRoomIdService } from './use-case/listene-message-delete-by-roomId.service';
|
||||
import { ListenMessageUpdateByRoomIdUseCase } from './use-case/listen-message-update-by-roomId.service';
|
||||
import { SyncAllRoomMessagesService } from './use-case/sync-all-room-messages.service';
|
||||
import { ListenSendMessageUseCase } from './use-case/listen-send-message.service'
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
@@ -42,7 +43,8 @@ export class ChatServiceService {
|
||||
private ListenMessageDeleteService: ListenMessageDeleteByRoomIdService,
|
||||
private ListenMessageUpdateByRoomIdUseCase: ListenMessageUpdateByRoomIdUseCase,
|
||||
private ListenSendMessageUseCase: ListenSendMessageUseCase,
|
||||
private MessageAttachmentByMessageIdService: MessageAttachmentByMessageIdUseCase
|
||||
private MessageAttachmentByMessageIdService: MessageAttachmentByMessageIdUseCase,
|
||||
private SyncAllRoomMessagesService: SyncAllRoomMessagesService
|
||||
) {
|
||||
this.messageLiveSignalRDataSourceService.getMessageDelete()
|
||||
.pipe()
|
||||
@@ -119,6 +121,10 @@ export class ChatServiceService {
|
||||
return this.MessageCreateUseCaseService.execute(input);
|
||||
}
|
||||
|
||||
asyncAllRoomMessage() {
|
||||
return this.SyncAllRoomMessagesService.execute()
|
||||
}
|
||||
|
||||
getMessageAttachmentByMessageId(input: MessageAttachmentByMessageIdInput) {
|
||||
return this.MessageAttachmentByMessageIdService.execute(input)
|
||||
}
|
||||
|
||||
@@ -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