diff --git a/srcs/requirements/nestjs/api_back/src/chat/chat.service.ts b/srcs/requirements/nestjs/api_back/src/chat/chat.service.ts index 315c2258..fa05248e 100644 --- a/srcs/requirements/nestjs/api_back/src/chat/chat.service.ts +++ b/srcs/requirements/nestjs/api_back/src/chat/chat.service.ts @@ -721,8 +721,8 @@ export class ChatService { const room = await this.getRoomByName(room_name); if(!room) { - printCallerError(`ERROR in chat: room not found for ${username}`); - return []; + console.log("throw error: error: true, code: 'ROOM_NOT_FOUND', message: 'room_not_found'"); + throw new HttpException({ error: true, code: 'ROOM_NOT_FOUND', message: `room_not_found` }, HttpStatus.NOT_FOUND); } if (!room.users.includes(username)) { @@ -731,8 +731,8 @@ export class ChatService { } if (room.type === "direct") { - console.log("throw error: error: true, code: 'LEAVE_DIRECY_FORBIDDEN', message: 'you cannot leave a direct messages conversation'"); - throw new HttpException({ error: true, code: 'LEAVE_DIRECY_FORBIDDEN', message: `you cannot leave a direct messages conversation` }, HttpStatus.FORBIDDEN); + console.log("throw error: error: true, code: 'LEAVE_DIRECT_FORBIDDEN', message: 'you cannot leave a direct messages conversation'"); + throw new HttpException({ error: true, code: 'LEAVE_DIRECT_FORBIDDEN', message: `you cannot leave a direct messages conversation` }, HttpStatus.FORBIDDEN); } // delete user from room @@ -749,6 +749,7 @@ export class ChatService { else if (room.users) { room.owner = room.users[0]; + room.admins = [room.users[0]]; messages.push(`${room.owner} is now owner of this room`); } else