invitation is working
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
### Pour lancer le docker :
|
### Pour lancer le docker :
|
||||||
|
|
||||||
- Il faut un fichier .env qu'on ne doit pas push, donc je ne le push pas.
|
- Il faut un fichier .env qu'on ne doit pas push, donc je ne le push pas.
|
||||||
@@ -79,7 +78,7 @@
|
|||||||
- [/] see all my rooms
|
- [/] see all my rooms
|
||||||
- [/] leave room
|
- [/] leave room
|
||||||
- [/] leave direct impossible
|
- [/] leave direct impossible
|
||||||
- [ ] invite someone in room
|
- [/] invite someone in room
|
||||||
- [ ] make admin
|
- [ ] make admin
|
||||||
- [ ] ban
|
- [ ] ban
|
||||||
- [ ] mute
|
- [ ] mute
|
||||||
|
|||||||
@@ -155,9 +155,9 @@ export class ChatController {
|
|||||||
console.log("- in inviteUser controller");
|
console.log("- in inviteUser controller");
|
||||||
|
|
||||||
let current_room_name = await this.chatService.getCurrentRoomName(req.user.username);
|
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");
|
console.log("- out inviteUser controller");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ export class ChatService {
|
|||||||
|
|
||||||
const user_db = await this.getUserByName(username);
|
const user_db = await this.getUserByName(username);
|
||||||
user_db.currentRoom = room_name;
|
user_db.currentRoom = room_name;
|
||||||
this.userRepository.save(user_db);
|
await this.userRepository.save(user_db);
|
||||||
|
|
||||||
console.log("-- out setCurrentRoom service");
|
console.log("-- out setCurrentRoom service");
|
||||||
return `room "${room_name}" is now current room`;
|
return `room "${room_name}" is now current room`;
|
||||||
@@ -237,7 +237,7 @@ export class ChatService {
|
|||||||
// update room with new user
|
// update room with new user
|
||||||
room.users.push(username);
|
room.users.push(username);
|
||||||
room.messages.push({ name: "SERVER", message: `${username} joined the room`});
|
room.messages.push({ name: "SERVER", message: `${username} joined the room`});
|
||||||
this.chatroomRepository.save(room);
|
await this.chatroomRepository.save(room);
|
||||||
|
|
||||||
console.log("-- out addUserToRoom service");
|
console.log("-- out addUserToRoom service");
|
||||||
return this.format_room(room);
|
return this.format_room(room);
|
||||||
@@ -253,7 +253,7 @@ export class ChatService {
|
|||||||
message: message,
|
message: message,
|
||||||
};
|
};
|
||||||
my_room.messages.push(chat_message);
|
my_room.messages.push(chat_message);
|
||||||
this.chatroomRepository.save(my_room);
|
await this.chatroomRepository.save(my_room);
|
||||||
|
|
||||||
console.log("-- out addMessageToRoom service");
|
console.log("-- out addMessageToRoom service");
|
||||||
}
|
}
|
||||||
@@ -275,7 +275,7 @@ export class ChatService {
|
|||||||
// delete user from room
|
// delete user from room
|
||||||
room.users.push(username);
|
room.users.push(username);
|
||||||
room.users = room.users.filter(name => name !== username);
|
room.users = room.users.filter(name => name !== username);
|
||||||
this.chatroomRepository.save(room);
|
await this.chatroomRepository.save(room);
|
||||||
|
|
||||||
// set current room to nothing
|
// set current room to nothing
|
||||||
await this.setCurrentRoom(username, "");
|
await this.setCurrentRoom(username, "");
|
||||||
|
|||||||
@@ -103,6 +103,8 @@ export async function invite_user(user_name: string)
|
|||||||
body: JSON.stringify({username: user_name}),
|
body: JSON.stringify({username: user_name}),
|
||||||
});
|
});
|
||||||
let data = await response.json();
|
let data = await response.json();
|
||||||
|
|
||||||
|
await get_room_messages();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function get_my_rooms()
|
export async function get_my_rooms()
|
||||||
|
|||||||
Reference in New Issue
Block a user