mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
set member to admin
This commit is contained in:
@@ -3,10 +3,12 @@ import { MessageDeleteLiveUseCaseService, MessageDeleteInputDTO } from 'src/app/
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { MessageReactionInput, MessageReactionUseCaseService } from 'src/app/module/chat/domain/use-case/message-reaction-use-case.service';
|
||||
import { MessageUpdateInput, MessageUpdateUseCaseService } from 'src/app/module/chat/domain/use-case/message-update-use-case.service';
|
||||
import { MemberAdminUseCaseService, MemberSetAdminDTO } from 'src/app/module/chat/domain/use-case/member-admin-use-case.service';
|
||||
import { SignalRService } from '../infra/socket/signal-r.service';
|
||||
import { SocketMessageDeleteUseCaseService } from 'src/app/module/chat/domain/use-case/socket/socket-message-delete-use-case.service';
|
||||
import { SocketMessageUpdateUseCaseService } from 'src/app/module/chat/domain/use-case/socket/socket-message-update-use-case.service';
|
||||
import { SocketMessageCreateUseCaseService } from 'src/app/module/chat/domain/use-case/socket/socket-message-create-use-case.service';
|
||||
import { MemberListUpdateStatusUseCaseService } from 'src/app/module/chat/domain/use-case/socket/member-list-update-status-use-case.service';
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { InstanceId } from '../data/repository/message-respository.service';
|
||||
|
||||
@@ -22,7 +24,9 @@ export class ChatServiceService {
|
||||
private SocketMessageDeleteUseCaseService: SocketMessageDeleteUseCaseService,
|
||||
private messageLiveSignalRDataSourceService: SignalRService,
|
||||
private SocketMessageUpdateUseCaseService: SocketMessageUpdateUseCaseService,
|
||||
private SocketMessageCreateUseCaseService: SocketMessageCreateUseCaseService
|
||||
private SocketMessageCreateUseCaseService: SocketMessageCreateUseCaseService,
|
||||
private MemberListUpdateStatusUseCaseService: MemberListUpdateStatusUseCaseService,
|
||||
private MemberAdminUseCaseService: MemberAdminUseCaseService
|
||||
) {
|
||||
this.messageLiveSignalRDataSourceService.getMessageDelete()
|
||||
.pipe()
|
||||
@@ -30,7 +34,6 @@ export class ChatServiceService {
|
||||
if(message?.id) {
|
||||
this.SocketMessageDeleteUseCaseService.execute(message)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
this.messageLiveSignalRDataSourceService.getMessageUpdate().pipe(
|
||||
@@ -38,7 +41,6 @@ export class ChatServiceService {
|
||||
return !message?.requestId?.startsWith(InstanceId)
|
||||
})
|
||||
).subscribe(async (message) => {
|
||||
|
||||
if(message?.id) {
|
||||
this.SocketMessageUpdateUseCaseService.execute(message)
|
||||
}
|
||||
@@ -61,6 +63,18 @@ export class ChatServiceService {
|
||||
|
||||
})
|
||||
|
||||
this.messageLiveSignalRDataSourceService.getData().pipe(
|
||||
filter((message) => {
|
||||
if(message?.method == 'AvailableUsers') {
|
||||
// console.log('exclude my message---')
|
||||
return true
|
||||
}
|
||||
})
|
||||
).subscribe(async (message) => {
|
||||
console.log('123', message)
|
||||
this.MemberListUpdateStatusUseCaseService.execute(message.data as any)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
messageDelete(data: {roomId, messageId}) {
|
||||
@@ -80,5 +94,9 @@ export class ChatServiceService {
|
||||
updateMessage(input: MessageUpdateInput) {
|
||||
return this.MessageUpdateUseCaseService.execute(input);
|
||||
}
|
||||
|
||||
setAdmin(input: MemberSetAdminDTO) {
|
||||
return this.MemberAdminUseCaseService.execute(input)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { TableMemberList } from "../../data/data-source/room/rooom-local-data-source.service";
|
||||
import { RoomByIdMemberItemOutputDTO } from "../../data/dto/room/roomByIdOutputDTO";
|
||||
|
||||
export function MemberListMapper(outputDto: RoomByIdMemberItemOutputDTO, roomId: string): TableMemberList {
|
||||
return {
|
||||
roomId: roomId,
|
||||
wxUserId: outputDto.user.wxUserId,
|
||||
wxFullName: outputDto.user.wxFullName,
|
||||
wxeMail: outputDto.user.wxFullName,
|
||||
userPhoto: outputDto.user.userPhoto,
|
||||
joinAt: outputDto.joinAt,
|
||||
isAdmin: outputDto.isAdmin
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { z } from "zod";
|
||||
import { RoomRepositoryService } from '../../data/repository/room-repository.service';
|
||||
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
|
||||
// Define the schema for the entire response
|
||||
const MemberSetAdminDTOSchema = z.object({
|
||||
roomId: z.string(),
|
||||
memberId: z.string()
|
||||
});
|
||||
|
||||
export type MemberSetAdminDTO = z.infer<typeof MemberSetAdminDTOSchema>
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class MemberAdminUseCaseService {
|
||||
|
||||
constructor(
|
||||
public repository: RoomRepositoryService
|
||||
) { }
|
||||
|
||||
@ValidateSchema(MemberSetAdminDTOSchema)
|
||||
execute(input: MemberSetAdminDTO) {
|
||||
|
||||
return this.repository.setAdmin(input)
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { z } from 'zod';
|
||||
import { MessageRepositoryService } from '../../data/repository/message-respository.service';
|
||||
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
|
||||
export const MessageDeleteInputDTOSchema = z.object({
|
||||
requestId: z.string(),
|
||||
requestId: z.string().optional(),
|
||||
roomId: z.string(),
|
||||
messageId: z.string(),
|
||||
senderId: z.number(),
|
||||
@@ -19,6 +20,7 @@ export class MessageDeleteLiveUseCaseService {
|
||||
public repository: MessageRepositoryService
|
||||
) { }
|
||||
|
||||
@ValidateSchema(MessageDeleteInputDTOSchema)
|
||||
async execute(data: MessageDeleteInputDTO) {
|
||||
return this.repository.sendMessageDelete(data)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MessageRepositoryService } from '../../data/repository/message-respository.service';
|
||||
import { object, z } from 'zod';
|
||||
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
|
||||
|
||||
const MessageReactionInputDTOSchema = z.object({
|
||||
@@ -8,7 +9,7 @@ const MessageReactionInputDTOSchema = z.object({
|
||||
messageId: z.string(),
|
||||
roomId: z.string(),
|
||||
reaction: z.string(),
|
||||
requestId: z.string()
|
||||
requestId: z.string().optional()
|
||||
})
|
||||
|
||||
export type MessageReactionInput = z.infer< typeof MessageReactionInputDTOSchema>
|
||||
@@ -22,6 +23,7 @@ export class MessageReactionUseCaseService {
|
||||
public repository: MessageRepositoryService
|
||||
) { }
|
||||
|
||||
@ValidateSchema(MessageReactionInputDTOSchema)
|
||||
execute(input: MessageReactionInput) {
|
||||
return this.repository.reactToMessage(input)
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { z } from 'zod';
|
||||
import { MessageRepositoryService } from '../../data/repository/message-respository.service';
|
||||
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
|
||||
const MessageUpdateInputDTOSchema = z.object({
|
||||
memberId: z.number(),
|
||||
messageId: z.string(),
|
||||
roomId: z.string(),
|
||||
message: z.string(),
|
||||
requestId: z.string()
|
||||
requestId: z.string().optional()
|
||||
})
|
||||
|
||||
export type MessageUpdateInput = z.infer< typeof MessageUpdateInputDTOSchema>
|
||||
@@ -22,8 +23,9 @@ export class MessageUpdateUseCaseService {
|
||||
public repository: MessageRepositoryService
|
||||
) { }
|
||||
|
||||
@ValidateSchema(MessageUpdateInputDTOSchema)
|
||||
execute(input: MessageUpdateInput) {
|
||||
this.repository.updateMessage(input);
|
||||
return this.repository.updateMessage(input);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { z } from 'zod';
|
||||
import { RoomRepositoryService } from 'src/app/module/chat/data/repository/room-repository.service'
|
||||
import { ValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
|
||||
export const MemberListUPdateStatus = z.object({
|
||||
key: z.string(),
|
||||
value: z.object({
|
||||
userId: z.number(),
|
||||
userName: z.string()
|
||||
})
|
||||
}).array();
|
||||
export type MemberListUPdateStatusInputDTO = z.infer<typeof MemberListUPdateStatus>
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class MemberListUpdateStatusUseCaseService {
|
||||
|
||||
constructor(
|
||||
private RoomRepositoryService: RoomRepositoryService
|
||||
) { }
|
||||
|
||||
|
||||
@ValidateSchema(MemberListUPdateStatus)
|
||||
execute(input: MemberListUPdateStatusInputDTO) {
|
||||
console.log
|
||||
return this.RoomRepositoryService.updateMemberStatus(input)
|
||||
}
|
||||
}
|
||||
+2
-4
@@ -12,16 +12,14 @@ export class SocketMessageCreateUseCaseService {
|
||||
|
||||
async execute(input: any) {
|
||||
|
||||
const id = input.id + ''
|
||||
delete input.id;
|
||||
|
||||
const incomingMessage = {
|
||||
...input,
|
||||
messageId: id,
|
||||
sending: false,
|
||||
roomId:input.chatRoomId
|
||||
}
|
||||
|
||||
delete input.chatRoomId
|
||||
|
||||
const result = await this.messageLocalDataSourceService.sendMessage(incomingMessage)
|
||||
|
||||
if(result.isOk()) {
|
||||
|
||||
+3
-6
@@ -13,19 +13,16 @@ export class SocketMessageUpdateUseCaseService {
|
||||
|
||||
|
||||
async execute(data: MessageOutPutDataDTO) {
|
||||
const result = await this.messageLocalDataSourceService.messageExist({messageId: data.id})
|
||||
|
||||
|
||||
const id = data.id + ''
|
||||
delete data.id;
|
||||
const result = await this.messageLocalDataSourceService.messageExist({id: data.id})
|
||||
|
||||
const incomingMessage = {
|
||||
...data,
|
||||
messageId: id,
|
||||
sending: false,
|
||||
roomId:data.chatRoomId
|
||||
}
|
||||
|
||||
// delete data.chatRoomId
|
||||
|
||||
if(result.isOk()) {
|
||||
console.log('message exist')
|
||||
return this.messageLocalDataSourceService.update({...result.value, ...incomingMessage})
|
||||
|
||||
Reference in New Issue
Block a user