Skip to content

Commit

Permalink
fix(chat): createRoom admin API participants validation (#1016)
Browse files Browse the repository at this point in the history
  • Loading branch information
kon14 authored Apr 22, 2024
1 parent ae7962d commit e7d2367
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/chat/src/admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class AdminHandlers {
}

async createRoom(call: ParsedRouterRequest): Promise<UnparsedRouterResponse> {
const { participants } = call.request.params;
const { participants } = call.request.params as { participants: string[] };
if (participants.length === 0) {
// array check is required
throw new GrpcError(
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit e7d2367

Please sign in to comment.