2024-08-02 16:20:26 +01:00
|
|
|
import { Injectable, Input } from '@angular/core';
|
|
|
|
|
import { MessageLocalDataSourceService } from '../../../data/data-source/message/message-local-data-source.service';
|
|
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
|
providedIn: 'root'
|
|
|
|
|
})
|
|
|
|
|
export class SocketMessageCreateUseCaseService {
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
private messageLocalDataSourceService: MessageLocalDataSourceService,
|
|
|
|
|
) { }
|
|
|
|
|
|
|
|
|
|
async execute(input: any) {
|
|
|
|
|
|
|
|
|
|
const incomingMessage = {
|
|
|
|
|
...input,
|
|
|
|
|
sending: false,
|
|
|
|
|
roomId:input.chatRoomId
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-06 11:24:00 +01:00
|
|
|
delete input.chatRoomId
|
|
|
|
|
|
2024-08-02 16:20:26 +01:00
|
|
|
const result = await this.messageLocalDataSourceService.sendMessage(incomingMessage)
|
|
|
|
|
|
|
|
|
|
if(result.isOk()) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
console.log(result.error)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|