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"];
|
let fields = ["name", "type", "users", "protection", "allowed_users"];
|
||||||
const rooms = await this.chatService.getMyRooms(req.user.username, fields);
|
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);
|
let new_room = this.format_room(room);
|
||||||
if (room.protection)
|
if (room.protection)
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ export async function remove_block_user(username: string): Promise<void>
|
|||||||
await fetch_chat_request('unblock', FetchMethod.POST, {username: username} );
|
await fetch_chat_request('unblock', FetchMethod.POST, {username: username} );
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function list_block_user(username: string): Promise<string>
|
export async function list_block_user(username: string): Promise<string[]>
|
||||||
{
|
{
|
||||||
to_print("in list_block_user");
|
to_print("in list_block_user");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user