Send avatarType explicitly in profile
This commit is contained in:
+10
-1
@@ -45,6 +45,14 @@ async function get(req, res, next) {
|
||||
const [error, backgroundImage] = await safe(users.getBackgroundImage(req.user.id));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
const [avatarError, avatar] = await safe(users.getAvatar(req.user.id));
|
||||
if (avatarError) return next(BoxError.toHttpError(error));
|
||||
|
||||
let avatarType;
|
||||
if (avatar.equals(constants.AVATAR_GRAVATAR)) avatarType = constants.AVATAR_GRAVATAR;
|
||||
else if (avatar.equals(constants.AVATAR_NONE)) avatarType = constants.AVATAR_NONE;
|
||||
else avatarType = constants.AVATAR_CUSTOM;
|
||||
|
||||
const { fqdn:dashboardFqdn } = await dashboard.getLocation();
|
||||
|
||||
next(new HttpSuccess(200, {
|
||||
@@ -57,7 +65,8 @@ async function get(req, res, next) {
|
||||
role: req.user.role,
|
||||
source: req.user.source,
|
||||
hasBackgroundImage: !!backgroundImage,
|
||||
avatarUrl: `https://${dashboardFqdn}/api/v1/profile/avatar/${req.user.id}`
|
||||
avatarUrl: `https://${dashboardFqdn}/api/v1/profile/avatar/${req.user.id}`,
|
||||
avatarType: avatarType.toString() // this is a Buffer
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user