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:
+16
-6
@@ -1,5 +1,8 @@
|
||||
import { Injectable, Input } from '@angular/core';
|
||||
import { MessageLocalDataSourceService } from '../../../data/data-source/message/message-local-data-source.service';
|
||||
import { TracingType, XTracerAsync } from 'src/app/services/monitoring/opentelemetry/tracer';
|
||||
import { ParamsValidation } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
import { MessageOutPutDataDTOSchema } from '../../../data/dto/message/messageOutputDTO';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -10,22 +13,29 @@ export class SocketMessageCreateUseCaseService {
|
||||
private messageLocalDataSourceService: MessageLocalDataSourceService,
|
||||
) { }
|
||||
|
||||
async execute(input: any) {
|
||||
@XTracerAsync({name:'Socket-Message-Create-UseCase', bugPrint: true})
|
||||
async execute(input: any, tracing?: TracingType) {
|
||||
|
||||
ParamsValidation(MessageOutPutDataDTOSchema, input, tracing)
|
||||
|
||||
const incomingMessage = {
|
||||
...input,
|
||||
sending: false,
|
||||
roomId:input.chatRoomId
|
||||
sending: false
|
||||
}
|
||||
|
||||
delete input.chatRoomId
|
||||
console.log('create message', {incomingMessage});
|
||||
|
||||
const result = await this.messageLocalDataSourceService.sendMessage(incomingMessage)
|
||||
tracing?.addEvent("Message Create start")
|
||||
const result = await this.messageLocalDataSourceService.createMessage(incomingMessage)
|
||||
tracing?.addEvent("Message Create end")
|
||||
|
||||
if(result.isOk()) {
|
||||
|
||||
} else {
|
||||
console.log(result.error)
|
||||
tracing?.addEvent("error while creating message")
|
||||
tracing.log("error while creating message", {
|
||||
error: result.error
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user