mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
receive message
This commit is contained in:
+12
-8
@@ -1,8 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MessageLocalDataSourceService } from '../../../data/data-source/message/message-local-data-source.service';
|
||||
import { MessageOutPutDataDTO, MessageOutPutDataDTOSchema } from '../../../data/dto/message/messageOutputDTO';
|
||||
import { SafeValidateSchema, ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
import { ParamsValidation, SafeValidateSchema, ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
import { MessageInputDTOSchema } from '../../../data/dto/message/messageInputDtO';
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -14,8 +15,12 @@ export class SocketMessageUpdateUseCaseService {
|
||||
) { }
|
||||
|
||||
|
||||
@SafeValidateSchema(MessageOutPutDataDTOSchema, 'SocketMessageUpdateUseCaseService')
|
||||
async execute(data: MessageOutPutDataDTO) {
|
||||
@XTracerAsync({name:'Socket-Message-Update-UseCase', bugPrint: true})
|
||||
async execute(data: MessageOutPutDataDTO, tracing?: TracingType) {
|
||||
|
||||
ParamsValidation(MessageOutPutDataDTOSchema, data, tracing)
|
||||
|
||||
tracing?.addEvent("Message existe?")
|
||||
const result = await this.messageLocalDataSourceService.messageExist({id: data.id})
|
||||
|
||||
const incomingMessage = {
|
||||
@@ -23,14 +28,13 @@ export class SocketMessageUpdateUseCaseService {
|
||||
sending: false
|
||||
}
|
||||
|
||||
// delete data.chatRoomId
|
||||
|
||||
if(result.isOk()) {
|
||||
console.log('message exist', result.value, incomingMessage)
|
||||
return this.messageLocalDataSourceService.update(result.value.$id, incomingMessage)
|
||||
tracing?.addEvent("Message found")
|
||||
return await this.messageLocalDataSourceService.update(result.value.$id, incomingMessage)
|
||||
} else {
|
||||
console.log('message else')
|
||||
tracing?.addEvent("Message not found")
|
||||
}
|
||||
|
||||
tracing.setAttribute('outcome', 'success')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user