diff --git a/backend/code/src/rooms/rooms.service.ts b/backend/code/src/rooms/rooms.service.ts index 17a263c..bbbad63 100644 --- a/backend/code/src/rooms/rooms.service.ts +++ b/backend/code/src/rooms/rooms.service.ts @@ -112,6 +112,18 @@ export class RoomsService { where: { id: roomData.roomId }, select: { type: true, password: true }, }); + + const count = await this.prisma.roomMember.aggregate({ + where: { + roomId: roomData.roomId, + }, + _count: { + userId: true, + } + }); + + if (count._count.userId > 20) + throw new HttpException('Room is full', HttpStatus.BAD_REQUEST); if (!room) throw new HttpException('room not found', HttpStatus.NOT_FOUND); if (room.type === 'protected' && !('password' in roomData)) throw new HttpException( @@ -530,6 +542,17 @@ export class RoomsService { }, }); + const count = await this.prisma.roomMember.aggregate({ + where: { + roomId: memberData.roomId, + }, + _count: { + userId: true, + } + }); + + if (count._count.userId >= 20) + throw new HttpException('Room is full', HttpStatus.BAD_REQUEST); if (!user || !user.is_admin || user.is_banned) throw new UnauthorizedException('You are not the admin of this Room'); if (member) throw new UnauthorizedException('User already Exist');