leaving message

This commit is contained in:
hugogogo
2023-01-13 15:52:38 +01:00
parent 5bcd52b573
commit f828419340
3 changed files with 12 additions and 4 deletions

View File

@@ -77,9 +77,9 @@
- [/] see all joignable rooms
- [/] cannot see private rooms
- [/] see all my rooms
- [/] invite someone in room
- [/] leave room
- [/] leave direct impossible
- [/] invite someone in room
- [ ] make admin
- [ ] ban
- [ ] mute

View File

@@ -190,6 +190,17 @@ export class ChatController {
const room_name = await this.chatService.getCurrentRoomName(req.user.username);
let response = await this.chatService.removeUserFromRoom(req.user.username, room_name);
// set current room to nothing
await this.chatService.setCurrentRoom(req.user.username, "");
// leaving message
let message = `${req.user.username} left the room`;
await this.chatService.addMessageToRoom(room_name, "SERVER", message);
let socket: socketDto = this.chatGateway.sockets.get(req.user.username);
await socket.to(socket.room).emit('message', "SERVER", message);
await socket.leave(socket.room);
res.status(HttpStatus.OK).json({ message: response });
console.log("- out leaveRoom controller");

View File

@@ -294,9 +294,6 @@ export class ChatService {
room.users = room.users.filter(name => name !== username);
await this.chatroomRepository.save(room);
// set current room to nothing
await this.setCurrentRoom(username, "");
console.log("-- out removeUserFromRoom service");
return "successfully leaving room";
}