will not show direct rooms if blocked

This commit is contained in:
simplonco
2023-01-16 16:18:42 +01:00
parent 61864af0a3
commit e52690d890
2 changed files with 16 additions and 2 deletions

View File

@@ -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)

View File

@@ -239,7 +239,7 @@ export async function remove_block_user(username: string): Promise<void>
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");