From 2453deeec361f95767d2e414040f6bc1114ee604 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 3 Jan 2020 17:37:47 +0100 Subject: [PATCH] Can display user account image in all cases --- src/controllers/UserController.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/controllers/UserController.ts b/src/controllers/UserController.ts index 23f4af6..801160f 100644 --- a/src/controllers/UserController.ts +++ b/src/controllers/UserController.ts @@ -76,7 +76,7 @@ export class UserController { "publicPage": user.pageStatus == UserPageStatus.PUBLIC, "openPage": user.pageStatus == UserPageStatus.OPEN, "virtualDirectory": user.hasVirtualDirectory ? user.virtualDirectory : "", - "accountImage": this.GetAccountImageURL(user.accountImage, h) + "accountImage": await this.GetAccountImageURL(user.accountImage, h) }; if(advanced) { @@ -98,22 +98,20 @@ export class UserController { return info; } - private static GetAccountImageURL(image : AccountImage, handler: RequestHandler) { + private static async 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; + if(!handler.signedIn) + return AccountImage.errorURL; + + if(image.level == AccountImageVisibilityLevel.COMUNIC_USERS + || await FriendsHelper.AreFriend(image.userID, handler.getUserId())) { + return image.url; } - // TODO : implement frienship support - console.error("ERR: Can not check friends for now (for account image)!"); - return AccountImage.errorURL; } } \ No newline at end of file