mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
recei and clear the code
This commit is contained in:
+27
-20
@@ -8,6 +8,7 @@ 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';
|
||||
import { MessageReactionInput } from '../../../domain/use-case/message-reaction-by-id-use-case.service';
|
||||
|
||||
interface msgObj {
|
||||
roomId: string;
|
||||
@@ -48,15 +49,18 @@ export class MessageSocketRepositoryService {
|
||||
return this.socket.establishConnection();
|
||||
}
|
||||
|
||||
async sendMessage(data: msgObj) {
|
||||
async join() {
|
||||
return await this.socket.join()
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await this.socket.sendMessage(data)
|
||||
return ok(result)
|
||||
} catch (e) {
|
||||
return err(e)
|
||||
}
|
||||
|
||||
async sendGroupMessage(data: MessageInputDTO) {
|
||||
const result = await this.socket.sendData<MessageOutPutDataDTO>({
|
||||
method: 'sendMessage',
|
||||
data: data,
|
||||
})
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async sendDirectMessage(data: MessageInputDTO) {
|
||||
@@ -86,6 +90,15 @@ export class MessageSocketRepositoryService {
|
||||
return result;
|
||||
}
|
||||
|
||||
async sendDelete(data: MessageDeleteInputDTO) {
|
||||
const result = await this.socket.sendData<any>({
|
||||
method: 'ReadAt',
|
||||
data: data,
|
||||
})
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
listenToMessages() {
|
||||
return this.socket.getMessage()
|
||||
}
|
||||
@@ -101,7 +114,7 @@ export class MessageSocketRepositoryService {
|
||||
}
|
||||
|
||||
|
||||
reactToMessageSocket(data) {
|
||||
reactToMessageSocket(data: MessageReactionInput) {
|
||||
this.socket.sendData({
|
||||
method: 'ReactMessage',
|
||||
data
|
||||
@@ -115,23 +128,17 @@ export class MessageSocketRepositoryService {
|
||||
})
|
||||
}
|
||||
|
||||
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)
|
||||
const result = this.socket.sendData<any>({
|
||||
method: 'DeleteMessage',
|
||||
data: data,
|
||||
})
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { RoomListItemOutPutDTO, RoomListOutPutDTO } from '../dto/room/roomListOutputDTO';
|
||||
import { RoomListItemOutPutDTO, RoomListOutPutDTO } from '../../dto/room/roomListOutputDTO';
|
||||
import { liveQuery, Observable } from 'Dexie';
|
||||
import { err, ok, Result } from 'neverthrow';
|
||||
import { z } from 'zod';
|
||||
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
import { chatDatabase } from '../../infra/database/dexie/service';
|
||||
import { RoomTable, RoomTableSchema } from '../../infra/database/dexie/schema/room';
|
||||
import { chatDatabase } from '../../../infra/database/dexie/service';
|
||||
import { RoomTable, RoomTableSchema } from '../../../infra/database/dexie/schema/room';
|
||||
import { DexieRepository } from 'src/app/infra/repository/dexie/dexie-repository.service';
|
||||
import { from } from 'rxjs';
|
||||
|
||||
+11
-11
@@ -1,21 +1,21 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Result } from 'neverthrow';
|
||||
import { HttpService } from 'src/app/services/http.service';
|
||||
import { RoomListOutPutDTO, RoomListOutPutDTOSchema } from '../dto/room/roomListOutputDTO';
|
||||
import { RoomInputDTO, RoomInputDTOSchema } from '../dto/room/roomInputDTO';
|
||||
import { RoomOutPutDTO, RoomOutPutDTOSchema } from '../dto/room/roomOutputDTO';
|
||||
import { AddMemberToRoomInputDTO, AddMemberToRoomInputDTOSchema } from '../dto/room/addMemberToRoomInputDto';
|
||||
import { RoomListOutPutDTO, RoomListOutPutDTOSchema } from '../../dto/room/roomListOutputDTO';
|
||||
import { RoomInputDTO, RoomInputDTOSchema } from '../../dto/room/roomInputDTO';
|
||||
import { RoomOutPutDTO, RoomOutPutDTOSchema } from '../../dto/room/roomOutputDTO';
|
||||
import { AddMemberToRoomInputDTO, AddMemberToRoomInputDTOSchema } from '../../dto/room/addMemberToRoomInputDto';
|
||||
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
import { RoomByIdInputDTO, RoomByIdInputDTOSchema } from '../dto/room/roomByIdInputDTO';
|
||||
import { RoomByIdOutputDTO, RoomByIdOutputDTOSchema } from '../dto/room/roomByIdOutputDTO';
|
||||
import { RoomByIdInputDTO, RoomByIdInputDTOSchema } from '../../dto/room/roomByIdInputDTO';
|
||||
import { RoomByIdOutputDTO, RoomByIdOutputDTOSchema } from '../../dto/room/roomByIdOutputDTO';
|
||||
import { APIReturn } from 'src/app/services/decorators/api-validate-schema.decorator';
|
||||
import { UserRemoveListInputDTO, UserRemoveListInputDTOSchema } from '../dto/room/userRemoveListInputDTO';
|
||||
import { RoomUpdateInputDTO, RoomUpdateInputDTOSchema } from '../dto/room/roomUpdateInputDTO';
|
||||
import { RoomUpdateOutputDTO } from '../dto/room/roomUpdateOutputDTO';
|
||||
import { UserRemoveListInputDTO, UserRemoveListInputDTOSchema } from '../../dto/room/userRemoveListInputDTO';
|
||||
import { RoomUpdateInputDTO, RoomUpdateInputDTOSchema } from '../../dto/room/roomUpdateInputDTO';
|
||||
import { RoomUpdateOutputDTO } from '../../dto/room/roomUpdateOutputDTO';
|
||||
import { DataSourceReturn } from 'src/app/services/Repositorys/type';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { MemberSetAdminDTO } from '../../domain/use-case/member-admin-use-case.service';
|
||||
import { SignalRService } from '../../infra/socket/signal-r.service';
|
||||
import { MemberSetAdminDTO } from '../../../domain/use-case/member-admin-use-case.service';
|
||||
import { SignalRService } from '../../../infra/socket/signal-r.service';
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
@Injectable({
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { RoomSocketRepositoryService } from './room-socket-repository.service';
|
||||
|
||||
describe('RoomSocketRepositoryService', () => {
|
||||
let service: RoomSocketRepositoryService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(RoomSocketRepositoryService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { SignalRService } from '../../../infra/socket/signal-r.service';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
import { z } from 'zod';
|
||||
import { SocketMessage } from '../../../infra/socket/signalR';
|
||||
|
||||
const listenToDeleteRoomInputSchema = z.object({
|
||||
roomId: z.string()
|
||||
})
|
||||
|
||||
export type ListenToDeleteRoomInput = z.infer<typeof listenToDeleteRoomInputSchema>
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class RoomSocketRepositoryService {
|
||||
|
||||
constructor(
|
||||
private socket: SignalRService
|
||||
) { }
|
||||
|
||||
listenToCreateRoom() {
|
||||
return this.socket.getData().pipe(
|
||||
filter((data) => data.method == 'UserAddGroup')
|
||||
)
|
||||
}
|
||||
|
||||
listenToDeleteRoom() {
|
||||
return this.socket.getData<any>().pipe(
|
||||
filter((data): data is SocketMessage<ListenToDeleteRoomInput> =>
|
||||
data?.method === 'UserRemoveGroup'
|
||||
),
|
||||
map((e) => e.data)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -8,14 +8,17 @@ import { SessionStore } from 'src/app/store/session.service';
|
||||
export class UserTypingRemoteRepositoryService {
|
||||
|
||||
constructor(
|
||||
private SignalRLiveDataSourceService: SignalRService
|
||||
private socket: SignalRService
|
||||
) { }
|
||||
|
||||
sendTyping(roomId, ) {
|
||||
return this.SignalRLiveDataSourceService.sendTyping({
|
||||
roomId,
|
||||
UserName:SessionStore.user.FullName,
|
||||
userId:SessionStore.user.UserId
|
||||
sendTyping(roomId) {
|
||||
return this.socket.sendData({
|
||||
method: 'Typing',
|
||||
data: {
|
||||
roomId,
|
||||
UserName:SessionStore.user.FullName,
|
||||
userId:SessionStore.user.UserId
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user