mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
add endpoint
This commit is contained in:
@@ -1,126 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MessageLiveDataSourceService } from '../../data-source/message/message-live-data-source.service';
|
||||
import { IncomingMessageSchema, MessageLocalDataSourceService } from '../../data-source/message/message-local-data-source.service';
|
||||
import { MessageRemoteDataSourceService } from '../../data-source/message/message-remote-data-source.service';
|
||||
import { SignalRService } from '../../../infra/socket/signal-r.service';
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { InstanceId } from '../../repository/message-respository.service';
|
||||
import { SafeValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
import { MessageOutPutDataDTO } from '../../dto/message/messageOutputDTO';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class MessageAsyncService {
|
||||
|
||||
constructor(
|
||||
private messageRemoteDataSourceService: MessageRemoteDataSourceService,
|
||||
private messageLiveDataSourceService: MessageLiveDataSourceService,
|
||||
private messageLiveSignalRDataSourceService: SignalRService,
|
||||
private messageLocalDataSourceService: MessageLocalDataSourceService
|
||||
) {
|
||||
|
||||
this.messageLiveSignalRDataSourceService.getMessage().pipe(
|
||||
filter((message) => {
|
||||
if(!message?.requestId?.startsWith(InstanceId) == false) {
|
||||
// console.log('exclude my message---')
|
||||
}
|
||||
return !message?.requestId?.startsWith(InstanceId)
|
||||
})
|
||||
).subscribe(async (message) => {
|
||||
|
||||
if(message?.id) {
|
||||
|
||||
// console.log('message async ', message)
|
||||
|
||||
const id = message.id + ''
|
||||
delete message.id;
|
||||
|
||||
const incomingMessage = {
|
||||
...message,
|
||||
messageId: id,
|
||||
sending: false,
|
||||
roomId:message.chatRoomId
|
||||
}
|
||||
|
||||
this.incomingMessage(incomingMessage)
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
this.messageLiveSignalRDataSourceService.getMessageUpdate().pipe(
|
||||
filter((message) => {
|
||||
return !message?.requestId?.startsWith(InstanceId)
|
||||
})
|
||||
).subscribe(async (message) => {
|
||||
|
||||
if(message?.id) {
|
||||
|
||||
console.log('message async ', message)
|
||||
|
||||
const id = message.id + ''
|
||||
delete message.id;
|
||||
|
||||
const incomingMessage = {
|
||||
...message,
|
||||
messageId: id,
|
||||
sending: false,
|
||||
roomId:message.chatRoomId
|
||||
}
|
||||
|
||||
this.incomingUpdateMessage(incomingMessage)
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
this.messageLiveSignalRDataSourceService.getMessageDelete()
|
||||
.pipe()
|
||||
.subscribe(async (message) => {
|
||||
if(message.id) {
|
||||
this.incomingDeleted(message)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@SafeValidateSchema(IncomingMessageSchema, 'socket/incomingMessage')
|
||||
async incomingMessage(IncomingMessageSchema: any) {
|
||||
|
||||
const result = await this.messageLocalDataSourceService.sendMessage(IncomingMessageSchema)
|
||||
|
||||
if(result.isOk()) {
|
||||
|
||||
} else {
|
||||
console.log(result.error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async incomingDeleted(data: MessageOutPutDataDTO) {
|
||||
const result = await this.messageLocalDataSourceService.deleteByMessageId(data.id)
|
||||
|
||||
if(result.isOk()) {
|
||||
|
||||
} else {
|
||||
console.log(result.error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async incomingUpdateMessage(data: MessageOutPutDataDTO & { messageId }) {
|
||||
const result = await this.messageLocalDataSourceService.messageExist({messageId: data.messageId})
|
||||
|
||||
if(result.isOk()) {
|
||||
console.log('message exist')
|
||||
return this.messageLocalDataSourceService.update({...result.value, ...data})
|
||||
} else {
|
||||
console.log('message else')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MessageLiveDataSourceService } from '../../data-source/message/message-live-data-source.service';
|
||||
import { RoomLiveDataSourceService } from '../../data-source/room/room-live-data-source.service';
|
||||
import { RoomRemoteDataSourceService } from '../../data-source/room/room-remote-data-source.service';
|
||||
import { roomDataSource, RoomLocalDataSourceService } from '../../data-source/room/rooom-local-data-source.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class RoomAsyncService {
|
||||
|
||||
constructor(
|
||||
private roomRemoteDataSourceService: RoomRemoteDataSourceService,
|
||||
// private roomMemoryDataSourceService: Store<RoomRemoteDataSourceState>,
|
||||
private roomLocalDataSourceService: RoomLocalDataSourceService,
|
||||
private roomLiveDataSourceService: RoomLiveDataSourceService,
|
||||
private messageLiveDataSourceService: MessageLiveDataSourceService,
|
||||
) {
|
||||
|
||||
|
||||
roomDataSource.typing.hook('creating', (primKey, obj, trans) => {
|
||||
setTimeout(() => {
|
||||
|
||||
}, 1000);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
incomingTyping() {
|
||||
|
||||
}
|
||||
|
||||
async removeUserTyping() {
|
||||
const result = await this.roomLocalDataSourceService.removeUserTyping()
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import { MessageLocalDataSourceService, TableMessage } from '../data-source/mess
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { SignalRService } from '../../infra/socket/signal-r.service';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { err, ok } from 'neverthrow';
|
||||
import { MessageDeleteInputDTO } from '../../domain/use-case/message-delete-live-use-case.service';
|
||||
import { MessageUpdateInput } from '../../domain/use-case/message-update-use-case.service';
|
||||
@@ -23,15 +22,7 @@ export class MessageRepositoryService {
|
||||
private messageLiveDataSourceService: MessageLiveDataSourceService,
|
||||
private messageLiveSignalRDataSourceService: SignalRService,
|
||||
private messageLocalDataSourceService: MessageLocalDataSourceService
|
||||
) {
|
||||
// this.messageLiveDataSourceService.socket.messages$.subscribe(({payload, requestId, type}) => {
|
||||
|
||||
|
||||
|
||||
|
||||
// })
|
||||
|
||||
}
|
||||
) {}
|
||||
|
||||
async sendMessage(data: MessageInputDTO) {
|
||||
|
||||
@@ -140,7 +131,6 @@ export class MessageRepositoryService {
|
||||
return this.messageLocalDataSourceService.getItemsLive(roomId)
|
||||
}
|
||||
|
||||
|
||||
subscribeToNewMessages(roomId: any) {
|
||||
return this.messageLocalDataSourceService.subscribeToNewMessage(roomId)
|
||||
}
|
||||
@@ -153,7 +143,4 @@ export class MessageRepositoryService {
|
||||
})
|
||||
}
|
||||
|
||||
getMemberByLive({roomId, userId}) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user