mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-20 08:35:17 +00:00
Start to process user account image
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import { RequestHandler } from "../entities/RequestHandler";
|
||||
import { UserHelper } from "../helpers/UserHelper";
|
||||
import { User, UserPageStatus } from "../entities/User";
|
||||
import { AccountImage, AccountImageVisibilityLevel } from "../entities/AccountImage";
|
||||
|
||||
/**
|
||||
* User information controller
|
||||
@ -20,7 +21,7 @@ export class UserController {
|
||||
if(!user)
|
||||
handler.error(404, "Could not get user data!");
|
||||
|
||||
handler.send(this.UserToAPI(user));
|
||||
handler.send(this.UserToAPI(user, handler));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -30,7 +31,7 @@ export class UserController {
|
||||
|
||||
}
|
||||
|
||||
private static UserToAPI(user : User) : any {
|
||||
private static UserToAPI(user : User, handler: RequestHandler) : Object {
|
||||
return {
|
||||
"userID": user.id,
|
||||
"firstName": user.firstName,
|
||||
@ -38,6 +39,26 @@ export class UserController {
|
||||
"publicPage": user.pageStatus == UserPageStatus.PUBLIC,
|
||||
"openPage": user.pageStatus == UserPageStatus.OPEN,
|
||||
"virtualDirectory": user.virtualDirectory,
|
||||
"accountImage": this.GetAccountImageURL(user.accountImage, handler)
|
||||
};
|
||||
}
|
||||
|
||||
private static GetAccountImageURL(image : AccountImage, handler: RequestHandler) {
|
||||
|
||||
if(image.level == AccountImageVisibilityLevel.EVERYONE
|
||||
|| (handler.signedIn && handler.getUserId() == image.userID))
|
||||
return image.url;
|
||||
|
||||
if(image.level == AccountImageVisibilityLevel.COMUNIC_USERS) {
|
||||
if(handler.signedIn)
|
||||
return image.url;
|
||||
else
|
||||
return AccountImage.errorURL;
|
||||
}
|
||||
|
||||
// TODO : implement frienship support
|
||||
console.error("ERR: Can not check friends for now (for account image)!");
|
||||
|
||||
return AccountImage.errorURL;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user