add block option

This commit is contained in:
2023-12-20 23:48:52 +01:00
parent 57ed6165ea
commit 4fd6616786
10 changed files with 154 additions and 44 deletions

View File

@ -12,8 +12,9 @@ class Profile
*/
this.client = client;
this.username = username;
this.avatar_url = avatar_url
this.user_id = user_id
this.avatar_url = avatar_url;
this.user_id = user_id;
this.isBlocked = false;
}
async init(user_id)
@ -24,7 +25,21 @@ class Profile
this.user_id = response_data.user_id;
this.username = response_data.username;
this.avatar_url = response_data.avatar_url;
let block_response = await this.client._get("/api/profiles/block");
if (block_response.status == 404)
return
let block_data = await block_response.json();
let block_list = JSON.parse(block_data);
block_list.forEach(block => {
let blocker = block.fields.blocker;
let blocked = block.fields.blocked;
if (blocker == this.client.me.user_id && blocked == user_id)
return this.isBlocked = true;
});
}
}
export {Profile}
export {Profile}