mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 21:35:50 +00:00
fix donwload attachment and modal to edit message
This commit is contained in:
@@ -4,11 +4,9 @@ import { AttachmentLocalDataSource } from "src/app/module/chat/data/repository/a
|
||||
import { z } from 'zod';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { InstanceId } from '../../chat-service.service';
|
||||
import { createDataURL } from 'src/app/utils/ToBase64';
|
||||
import { createBlobFromBase64, createDataURL } from 'src/app/utils/ToBase64';
|
||||
import { zodSafeValidation } from 'src/app/utils/zodValidation';
|
||||
import { Logger } from 'src/app/services/logger/main/service';
|
||||
import { MessageLocalDataSourceService } from '../../../data/repository/message/message-local-data-source.service';
|
||||
import { MessageSocketRepositoryService } from '../../../data/repository/message/message-live-signalr-data-source.service';
|
||||
import { err, Result } from 'neverthrow';
|
||||
import { MessageMapper } from '../../mapper/messageMapper';
|
||||
import { RoomType } from "src/app/core/chat/entity/group";
|
||||
@@ -17,6 +15,10 @@ import { MemberListLocalRepository } from 'src/app/module/chat/data/repository/m
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { MessageTable } from 'src/app/infra/database/dexie/instance/chat/schema/message';
|
||||
import { MessageAttachmentFileType, MessageOutPutDataDTO } from 'src/app/core/chat/repository/dto/messageOutputDTO';
|
||||
import { IMessageLocalRepository } from 'src/app/core/chat/repository/message/message-local-repository';
|
||||
import { IMessageSocketRepository } from 'src/app/core/chat/repository/message/message-socket-repository';
|
||||
import { IMemberLocalRepository } from 'src/app/core/chat/repository/member/member-local-repository';
|
||||
import { IAttachmentLocalRepository } from 'src/app/core/chat/repository/typing/typing-local-repository';
|
||||
|
||||
|
||||
export enum MessageEnum {
|
||||
@@ -71,11 +73,10 @@ export type MessageCreateOutPutDataDTO = z.infer<typeof MessageCreatePutDataDTOS
|
||||
export class MessageCreateUseCaseService {
|
||||
|
||||
constructor(
|
||||
private AttachmentLocalRepositoryService: AttachmentLocalDataSource,
|
||||
private messageLocalDataSourceService: MessageLocalDataSourceService,
|
||||
private MessageSocketRepositoryService: MessageSocketRepositoryService,
|
||||
private messageSocketRepositoryService: MessageSocketRepositoryService,
|
||||
private MemberListLocalRepository: MemberListLocalRepository
|
||||
private AttachmentLocalRepositoryService: IAttachmentLocalRepository,
|
||||
private messageLocalDataSourceService: IMessageLocalRepository,
|
||||
private messageSocketRepositoryService: IMessageSocketRepository,
|
||||
private MemberListLocalRepository: IMemberLocalRepository
|
||||
) { }
|
||||
|
||||
|
||||
@@ -104,7 +105,7 @@ export class MessageCreateUseCaseService {
|
||||
|
||||
this.AttachmentLocalRepositoryService.insert({
|
||||
$messageId: createMessageLocally.value,
|
||||
file: createDataURL(attachment.file, attachment.mimeType),
|
||||
base64: createDataURL(attachment.file, attachment.mimeType),
|
||||
fileType: attachment.fileType,
|
||||
source: attachment.source,
|
||||
fileName: attachment.fileName,
|
||||
@@ -133,7 +134,7 @@ export class MessageCreateUseCaseService {
|
||||
let sendMessageResult: Result<MessageOutPutDataDTO, any>
|
||||
if(messageEnum == RoomType.Group) {
|
||||
const DTO = MessageMapper.fromDomain(message, message.requestId)
|
||||
sendMessageResult = await this.MessageSocketRepositoryService.sendGroupMessage(DTO)
|
||||
sendMessageResult = await this.messageSocketRepositoryService.sendGroupMessage(DTO)
|
||||
} else {
|
||||
|
||||
if(message.receiverId) {
|
||||
@@ -182,6 +183,10 @@ export class MessageCreateUseCaseService {
|
||||
return err('no connection')
|
||||
}
|
||||
|
||||
} else {
|
||||
Logger.error('failed to insert locally', {
|
||||
error: createMessageLocally.error
|
||||
})
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user