mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
fix delete message on ui layer
This commit is contained in:
+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