2023-12-08 11:36:41 -05:00
|
|
|
import { Profile } from "./profile.js";
|
|
|
|
|
|
|
|
class Profiles
|
|
|
|
{
|
2023-12-16 12:00:38 -05:00
|
|
|
/**
|
|
|
|
* @param {Client} client
|
|
|
|
*/
|
2023-12-08 11:36:41 -05:00
|
|
|
constructor (client)
|
|
|
|
{
|
2023-12-16 12:00:38 -05:00
|
|
|
/**
|
|
|
|
* @type {Client} client
|
|
|
|
*/
|
2023-12-08 11:36:41 -05:00
|
|
|
this.client = client
|
|
|
|
}
|
|
|
|
|
|
|
|
async all()
|
|
|
|
{
|
|
|
|
let response = await this.client._get("/api/profiles/");
|
|
|
|
let response_data = await response.json();
|
|
|
|
|
|
|
|
let profiles = []
|
|
|
|
response_data.forEach((profile) => {
|
|
|
|
profiles.push(new Profile(this.client, profile.username, profile.avatar_url, profile.user_id))
|
|
|
|
});
|
2023-12-09 09:13:40 -05:00
|
|
|
return profiles;
|
2023-12-08 11:36:41 -05:00
|
|
|
}
|
2023-12-09 15:51:32 -05:00
|
|
|
|
|
|
|
async getProfile(user_id)
|
|
|
|
{
|
|
|
|
let profile = new Profile(this.client);
|
|
|
|
await profile.init(user_id);
|
|
|
|
return profile;
|
|
|
|
}
|
2023-12-19 05:27:18 -05:00
|
|
|
|
|
|
|
async block(user_id) {
|
|
|
|
|
|
|
|
// blocker & blocked
|
|
|
|
let response = await this.client._post("/api/block/",
|
|
|
|
[this.client.me.user_id, user_id],
|
|
|
|
);
|
|
|
|
|
|
|
|
let data = await response.json();
|
|
|
|
|
|
|
|
}
|
2023-12-08 11:36:41 -05:00
|
|
|
}
|
|
|
|
|
2023-12-19 05:27:18 -05:00
|
|
|
export {Profiles}
|