will not show direct rooms if blocked
This commit is contained in:
@@ -52,8 +52,22 @@ export class ChatController {
|
||||
|
||||
let fields = ["name", "type", "users", "protection", "allowed_users"];
|
||||
const rooms = await this.chatService.getMyRooms(req.user.username, fields);
|
||||
const blocked = await this.chatService.getListBlockUser(req.user.username);
|
||||
|
||||
const ret_rooms = rooms.map(room =>
|
||||
let filtered_rooms = rooms.filter(room =>
|
||||
{
|
||||
if (room.type === 'direct')
|
||||
{
|
||||
let roomname = room.users[0];
|
||||
if (roomname === req.user.username)
|
||||
roomname = room.users[1];
|
||||
if (blocked.includes(roomname))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
const ret_rooms = filtered_rooms.map(room =>
|
||||
{
|
||||
let new_room = this.format_room(room);
|
||||
if (room.protection)
|
||||
|
||||
Reference in New Issue
Block a user