added severall protections
This commit is contained in:
@@ -231,6 +231,13 @@ export class ChatController {
|
||||
console.log("throw error: error: true, code: 'BLOCKED_USER', message: 'you cannot enter this room, you blocked this user'");
|
||||
throw new HttpException({ error: true, code: 'BLOCKED_USER', message: `you cannot enter this room, you blocked this user` }, HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
const find_room = await this.chatService.getRoomByName(`${req.user.username} + ${room.name}`);
|
||||
if (find_room)
|
||||
{
|
||||
console.log("throw error: error: true, code: 'ROOM_CONFLICT', message: 'This room name already exist'");
|
||||
throw new HttpException({ error: true, code: 'ROOM_CONFLICT', message: `This room name already exist` }, HttpStatus.CONFLICT);
|
||||
}
|
||||
room.type = 'direct';
|
||||
room.users = [room.name, req.user.username];
|
||||
room.name += ` + ${req.user.username}`;
|
||||
|
||||
Reference in New Issue
Block a user