invitation is working
This commit is contained in:
@@ -155,9 +155,9 @@ export class ChatController {
|
||||
console.log("- in inviteUser controller");
|
||||
|
||||
let current_room_name = await this.chatService.getCurrentRoomName(req.user.username);
|
||||
await this.chatService.addUserToRoom(username, current_room_name);
|
||||
let room = await this.chatService.addUserToRoom(username, current_room_name);
|
||||
|
||||
res.status(HttpStatus.OK);
|
||||
res.status(HttpStatus.OK).json({ room: room });
|
||||
|
||||
console.log("- out inviteUser controller");
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ export class ChatService {
|
||||
|
||||
const user_db = await this.getUserByName(username);
|
||||
user_db.currentRoom = room_name;
|
||||
this.userRepository.save(user_db);
|
||||
await this.userRepository.save(user_db);
|
||||
|
||||
console.log("-- out setCurrentRoom service");
|
||||
return `room "${room_name}" is now current room`;
|
||||
@@ -237,7 +237,7 @@ export class ChatService {
|
||||
// update room with new user
|
||||
room.users.push(username);
|
||||
room.messages.push({ name: "SERVER", message: `${username} joined the room`});
|
||||
this.chatroomRepository.save(room);
|
||||
await this.chatroomRepository.save(room);
|
||||
|
||||
console.log("-- out addUserToRoom service");
|
||||
return this.format_room(room);
|
||||
@@ -253,7 +253,7 @@ export class ChatService {
|
||||
message: message,
|
||||
};
|
||||
my_room.messages.push(chat_message);
|
||||
this.chatroomRepository.save(my_room);
|
||||
await this.chatroomRepository.save(my_room);
|
||||
|
||||
console.log("-- out addMessageToRoom service");
|
||||
}
|
||||
@@ -275,7 +275,7 @@ export class ChatService {
|
||||
// delete user from room
|
||||
room.users.push(username);
|
||||
room.users = room.users.filter(name => name !== username);
|
||||
this.chatroomRepository.save(room);
|
||||
await this.chatroomRepository.save(room);
|
||||
|
||||
// set current room to nothing
|
||||
await this.setCurrentRoom(username, "");
|
||||
|
||||
@@ -103,6 +103,8 @@ export async function invite_user(user_name: string)
|
||||
body: JSON.stringify({username: user_name}),
|
||||
});
|
||||
let data = await response.json();
|
||||
|
||||
await get_room_messages();
|
||||
}
|
||||
|
||||
export async function get_my_rooms()
|
||||
|
||||
Reference in New Issue
Block a user