mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-21 00:55:17 +00:00
Start to give advanced info about users
This commit is contained in:
@ -21,7 +21,7 @@ export class UserController {
|
||||
if(!user)
|
||||
handler.error(404, "Could not get user data!");
|
||||
|
||||
handler.send(this.UserToAPI(user, handler));
|
||||
handler.send(await this.UserToAPI(user, handler));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,7 +41,7 @@ export class UserController {
|
||||
if(!user)
|
||||
handler.error(404, "One user was not found!");
|
||||
|
||||
list[id] = this.UserToAPI(user, handler);
|
||||
list[id] = await this.UserToAPI(user, handler);
|
||||
}
|
||||
|
||||
handler.send(list);
|
||||
@ -58,12 +58,15 @@ export class UserController {
|
||||
if(!await UserHelper.CanSeeUserPage(h.optionnalUserID, userID))
|
||||
h.error(401, "You are not allowed to access these information!");
|
||||
|
||||
h.send("Go on");
|
||||
const user = await UserHelper.GetUserInfo(userID);
|
||||
const result = this.UserToAPI(user, h, true);
|
||||
|
||||
h.send(await result);
|
||||
}
|
||||
|
||||
|
||||
private static UserToAPI(user : User, handler: RequestHandler) : Object {
|
||||
return {
|
||||
private static async UserToAPI(user : User, handler: RequestHandler, advanced: boolean = false) : Promise<Object> {
|
||||
const info = {
|
||||
"userID": user.id,
|
||||
"firstName": user.firstName,
|
||||
"lastName": user.lastName,
|
||||
@ -72,6 +75,18 @@ export class UserController {
|
||||
"virtualDirectory": user.virtualDirectory,
|
||||
"accountImage": this.GetAccountImageURL(user.accountImage, handler)
|
||||
};
|
||||
|
||||
if(advanced) {
|
||||
info["friend_list_public"] = user.friendsListPublic;
|
||||
info["personnalWebsite"] = user.hasWebsite ? user.personnalWebsite : "";
|
||||
info["publicNote"] = user.hasPublicNote ? user.publicNote : "";
|
||||
info["noCommentOnHisPage"] = user.blockComments;
|
||||
info["allowPostFromFriendOnHisPage"] = user.allowPostsFromFriends;
|
||||
info["account_creation_time"] = user.timeCreate;
|
||||
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
private static GetAccountImageURL(image : AccountImage, handler: RequestHandler) {
|
||||
|
Reference in New Issue
Block a user