mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
38 lines
961 B
TypeScript
38 lines
961 B
TypeScript
|
|
import { Injectable } from '@angular/core';
|
||
|
|
import { MessageLocalDataSourceService } from '../../../data/data-source/message/message-local-data-source.service';
|
||
|
|
import { MessageOutPutDataDTO } from '../../../data/dto/message/messageOutputDTO';
|
||
|
|
|
||
|
|
@Injectable({
|
||
|
|
providedIn: 'root'
|
||
|
|
})
|
||
|
|
export class SocketMessageUpdateUseCaseService {
|
||
|
|
|
||
|
|
constructor(
|
||
|
|
private messageLocalDataSourceService: MessageLocalDataSourceService
|
||
|
|
) { }
|
||
|
|
|
||
|
|
|
||
|
|
async execute(data: MessageOutPutDataDTO) {
|
||
|
|
const result = await this.messageLocalDataSourceService.messageExist({messageId: data.id})
|
||
|
|
|
||
|
|
|
||
|
|
const id = data.id + ''
|
||
|
|
delete data.id;
|
||
|
|
|
||
|
|
const incomingMessage = {
|
||
|
|
...data,
|
||
|
|
messageId: id,
|
||
|
|
sending: false,
|
||
|
|
roomId:data.chatRoomId
|
||
|
|
}
|
||
|
|
|
||
|
|
if(result.isOk()) {
|
||
|
|
console.log('message exist')
|
||
|
|
return this.messageLocalDataSourceService.update({...result.value, ...incomingMessage})
|
||
|
|
} else {
|
||
|
|
console.log('message else')
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|