mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
fix delete message on ui layer
This commit is contained in:
@@ -27,7 +27,6 @@ export class MessageLocalDataSourceService extends DexieRepository<MessageTable,
|
||||
chatDatabase.message.hook('creating', (primaryKey, obj, transaction) => {
|
||||
|
||||
this.creatingSubject.next(obj)
|
||||
console.log('creating', obj)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ import { MessageMarkAllMessageAsReadByRoomIdInputSchema, MessageMarkAllMessageAs
|
||||
import { GetRoomListUseCaseService } from 'src/app/module/chat/domain/use-case/room/room-get-list-use-case.service';
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { MessageEntity } from '../../../core/chat/entity/message';
|
||||
import { MessageAttachmentByMessageIdUseCase } from './use-case/message/message-attachment-by-message-id.service';
|
||||
import { IMessage, MessageEntity } from '../../../core/chat/entity/message';
|
||||
import { MessageAttachmentByMessageIdInput, MessageAttachmentByMessageIdUseCase } from './use-case/message/message-attachment-by-message-id.service';
|
||||
import { AddMemberToRoomInputDTO } from '../domain/use-case/member/member-add-use-case.service';
|
||||
import { RoomType } from "src/app/core/chat/entity/group";
|
||||
import { HttpListenToMessageLoadHistoryAdapter } from './adapter'
|
||||
@@ -167,7 +167,7 @@ export class ChatServiceService {
|
||||
return this.MemberAdminUseCaseService.execute(input)
|
||||
}
|
||||
|
||||
sendMessage(input: MessageEntity, messageEnum: RoomType) {
|
||||
sendMessage(input: IMessage, messageEnum: RoomType) {
|
||||
return this.MessageCreateUseCaseService.execute(input, messageEnum);
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ export class ChatServiceService {
|
||||
return this.SyncAllRoomMessagesService.execute()
|
||||
}
|
||||
|
||||
getMessageAttachmentByMessageId(input: MessageEntity) {
|
||||
getMessageAttachmentByMessageId(input: MessageAttachmentByMessageIdInput) {
|
||||
return this.MessageAttachmentByMessageIdService.execute(input)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { MessageEntity } from "../../../../core/chat/entity/message";
|
||||
import { MessageEntity, IMessage } from "../../../../core/chat/entity/message";
|
||||
import { MessageOutPutDataDTO } from "src/app/core/chat/repository/dto/messageOutputDTO";
|
||||
import { MessageInputDTO } from "../use-case/message/message-create-use-case.service";
|
||||
|
||||
@@ -7,7 +7,7 @@ export class MessageMapper {
|
||||
return DTO as MessageEntity
|
||||
}
|
||||
|
||||
static fromDomain(entity:MessageEntity, requestId): MessageInputDTO {
|
||||
static fromDomain(entity:IMessage, requestId): MessageInputDTO {
|
||||
return {
|
||||
receiverId: entity.receiverId,
|
||||
canEdit: entity.canEdit,
|
||||
|
||||
+10
-9
@@ -4,15 +4,14 @@ import { AttachmentRemoteDataSourceService } from 'src/app/module/chat/data/repo
|
||||
import { AttachmentLocalDataSource } from 'src/app/module/chat/data/repository/attachment/attachment-local-repository.service'
|
||||
import { createBlobUrl } from 'src/app/utils/ToBase64';
|
||||
import { err, Result } from 'neverthrow';
|
||||
import { Logger } from 'src/app/services/logger/main/service';
|
||||
import { MessageEntity } from '../../../../../core/chat/entity/message';
|
||||
import { AttachmentTableSchema } from 'src/app/infra/database/dexie/instance/chat/schema/attachment';
|
||||
import { MessageEntitySchema } from '../../../../../core/chat/entity/message';
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { isHttpResponse } from 'src/app/infra/http/http.service';
|
||||
|
||||
const MessageAttachmentByMessageIdSchema = AttachmentTableSchema.pick({
|
||||
$messageId: true,
|
||||
id: true
|
||||
const MessageAttachmentByMessageIdSchema = MessageEntitySchema.pick({
|
||||
$id: true,
|
||||
id: true,
|
||||
attachments: true,
|
||||
})
|
||||
|
||||
export type MessageAttachmentByMessageIdInput = z.infer<typeof MessageAttachmentByMessageIdSchema>
|
||||
@@ -28,7 +27,9 @@ export class MessageAttachmentByMessageIdUseCase {
|
||||
) { }
|
||||
|
||||
@XTracerAsync({name:'Message-Attachment-By-MessageIdUseCase', module:'chat', bugPrint: true, waitNThrow: 15000})
|
||||
async execute(input: MessageEntity, tracing?: TracingType): Promise<Result<string, any>> {
|
||||
async execute(input: MessageAttachmentByMessageIdInput, tracing?: TracingType): Promise<Result<string, any>> {
|
||||
|
||||
tracing.setAttribute('messageId', input.id)
|
||||
|
||||
const getLocalAttachment = await this.AttachmentLocalDataSource.findOne({
|
||||
$messageId: input.$id
|
||||
@@ -60,8 +61,9 @@ export class MessageAttachmentByMessageIdUseCase {
|
||||
|
||||
} else {
|
||||
tracing.setAttribute('download', 'true')
|
||||
const result = await this.AttachmentRemoteDataSourceService.getAttachment(input.attachments[0].id)
|
||||
tracing.setAttribute('attachmentId', input.attachments[0].id.toString())
|
||||
|
||||
const result = await this.AttachmentRemoteDataSourceService.getAttachment(input.attachments[0].id)
|
||||
if(result.isErr()) {
|
||||
tracing.hasError('failed to download message attachment', {
|
||||
error: result.error,
|
||||
@@ -78,7 +80,6 @@ export class MessageAttachmentByMessageIdUseCase {
|
||||
|
||||
if(result.isOk()) {
|
||||
|
||||
console.log('convert')
|
||||
const dataUrl = await createBlobUrl(result.value)
|
||||
|
||||
if(dataUrl.isOk()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MessageAttachmentSource, MessageEntity, MessageEntitySchema, } from '../../../../../core/chat/entity/message';
|
||||
import { IMessage, MessageAttachmentSource, MessageEntity, MessageEntitySchema, } from '../../../../../core/chat/entity/message';
|
||||
import { AttachmentLocalDataSource } from "src/app/module/chat/data/repository/attachment/attachment-local-repository.service";
|
||||
import { z } from 'zod';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
@@ -100,9 +100,9 @@ export class MessageCreateUseCaseService {
|
||||
|
||||
|
||||
@XTracerAsync({name:'MessageCreateUseCaseService', module:'chat', bugPrint: true, waitNThrow: 5000})
|
||||
async execute(message: MessageEntity, messageEnum: RoomType, tracing?: TracingType) {
|
||||
async execute(message: IMessage, messageEnum: RoomType, tracing?: TracingType) {
|
||||
|
||||
const validation = zodSafeValidation<MessageEntity>(MessageEntitySchema, message)
|
||||
const validation = zodSafeValidation<IMessage>(MessageEntitySchema, message)
|
||||
|
||||
if(validation.isOk()) {
|
||||
message.sendAttemp++;
|
||||
|
||||
+9
-1
@@ -24,6 +24,14 @@ export class MessageMarkAsReadUseCaseService {
|
||||
|
||||
@XTracerAsync({name:'MessageMarkAsReadUseCaseService', module:'chat', bugPrint: true})
|
||||
async execute(sendReadAt: MessageMarkAsReadInput, tracing?: TracingType) {
|
||||
return this.MessageSocketRepositoryService.sendReadAt(sendReadAt as any)
|
||||
const result = await this.MessageSocketRepositoryService.sendReadAt(sendReadAt as any)
|
||||
|
||||
if(result.isErr()) {
|
||||
tracing.setAttribute('meesageId', sendReadAt.messageId)
|
||||
tracing.hasError('failed to read message')
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,6 @@ export class GetRoomByIdUseCaseService {
|
||||
|
||||
const getRoomById = await this.roomLocalDataSourceService.findOne({id:validData.value.data.id})
|
||||
if(getRoomById.isOk() && getRoomById.value) {
|
||||
console.log(validData.value)
|
||||
const room = GetRoomByIdMapper.toDomain(validData.value)
|
||||
|
||||
const added: Partial<RoomEntity> = addedDiff(getRoomById.value, room);
|
||||
@@ -90,7 +89,6 @@ export class GetRoomByIdUseCaseService {
|
||||
}
|
||||
|
||||
} else if (getRoomById.isOk() && !getRoomById.value) {
|
||||
console.log(validData.value)
|
||||
const room = GetRoomByIdMapper.toDomain(validData.value)
|
||||
this.roomLocalDataSourceService.insert(room)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user