set member to admin

This commit is contained in:
Peter Maquiran
2024-08-06 11:24:00 +01:00
parent 7e14f55383
commit 2f214e0025
3889 changed files with 581 additions and 1962886 deletions
@@ -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);
}
}
@@ -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)
}
}
@@ -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()) {
@@ -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})