mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
create direct message
This commit is contained in:
+99
@@ -0,0 +1,99 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { err, ok } from 'neverthrow';
|
||||
import { SignalRService } from '../../../infra/socket/signal-r.service';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { MessageDeleteInputDTO } from '../../dto/message/messageDeleteInputDTO';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { InstanceId } from '../../../domain/chat-service.service';
|
||||
import { MessageUpdateInput } from '../../../domain/use-case/message-update-by-id-use-case.service';
|
||||
import { MessageOutPutDataDTO } from '../../dto/message/messageOutputDTO';
|
||||
import { MessageInputDTO } from '../../dto/message/messageInputDtO';
|
||||
|
||||
interface msgObj {
|
||||
roomId: string;
|
||||
senderId: string;
|
||||
message:string;
|
||||
messageType:1;
|
||||
canEdit:Boolean;
|
||||
oneShot:Boolean;
|
||||
requestId: string;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class MessageSocketRepositoryService {
|
||||
|
||||
constructor(
|
||||
private socket: SignalRService
|
||||
) {}
|
||||
|
||||
async sendMessage(data: msgObj) {
|
||||
|
||||
try {
|
||||
const result = await this.socket.sendMessage(data)
|
||||
return ok(result)
|
||||
} catch (e) {
|
||||
return err(e)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async sendDirectMessage(data: MessageInputDTO) {
|
||||
const result = await this.socket.sendData<MessageOutPutDataDTO>({
|
||||
method: 'SendDirectMessage',
|
||||
data: data as any,
|
||||
})
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
listenToMessages() {
|
||||
return this.socket.getMessage()
|
||||
}
|
||||
|
||||
|
||||
listenToDeleteMessages() {
|
||||
return this.socket.getMessageDelete()
|
||||
}
|
||||
|
||||
|
||||
listenToUpdateMessages() {
|
||||
return this.socket.getMessageUpdate()
|
||||
}
|
||||
|
||||
|
||||
reactToMessageSocket(data) {
|
||||
this.socket.sendData({
|
||||
method: 'ReactMessage',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
updateMessage(input: MessageUpdateInput) {
|
||||
this.socket.sendData({
|
||||
method: 'EditMessage',
|
||||
data: input,
|
||||
})
|
||||
}
|
||||
|
||||
sendTyping(roomId) {
|
||||
return this.socket.sendTyping({
|
||||
roomId,
|
||||
UserName:SessionStore.user.FullName,
|
||||
userId: SessionStore.user.UserId
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
sendMessageDelete(data: MessageDeleteInputDTO) {
|
||||
|
||||
data['requestId'] = InstanceId +'@'+ uuidv4();
|
||||
|
||||
return this.socket.sendMessageDelete(data)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user