leaving message
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user