From e7d2367e60499da0b9b8a5cc63ed9a4da60bcfaf Mon Sep 17 00:00:00 2001 From: Konstantinos Feretos Date: Mon, 22 Apr 2024 17:29:55 +0300 Subject: [PATCH] fix(chat): createRoom admin API participants validation (#1016) --- modules/chat/src/admin/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/chat/src/admin/index.ts b/modules/chat/src/admin/index.ts index f7d4456cc..89f8a4b50 100644 --- a/modules/chat/src/admin/index.ts +++ b/modules/chat/src/admin/index.ts @@ -66,7 +66,7 @@ export class AdminHandlers { } async createRoom(call: ParsedRouterRequest): Promise { - const { participants } = call.request.params; + const { participants } = call.request.params as { participants: string[] }; if (participants.length === 0) { // array check is required throw new GrpcError( @@ -250,10 +250,10 @@ export class AdminHandlers { this.routingManager.registerRoutes(); } - private async validateUsersInput(users: User[]) { + private async validateUsersInput(users: string[]) { const uniqueUsers = Array.from(new Set(users)); const usersToBeAdded: void | User[] = await User.getInstance().findMany({ - _id: { $in: uniqueUsers.map(user => user._id) }, + _id: { $in: uniqueUsers }, }); if (isNil(usersToBeAdded)) { throw new GrpcError(status.NOT_FOUND, 'Users do not exist');