Always send images for profile
This commit is contained in:
+10
-2
@@ -23,6 +23,7 @@ const assert = require('assert'),
|
||||
HttpError = require('connect-lastmile').HttpError,
|
||||
HttpSuccess = require('connect-lastmile').HttpSuccess,
|
||||
safe = require('safetydance'),
|
||||
superagent = require('superagent'),
|
||||
users = require('../users.js');
|
||||
|
||||
async function canEditProfile(req, res, next) {
|
||||
@@ -121,8 +122,15 @@ async function getAvatar(req, res, next) {
|
||||
const [error, avatar] = await safe(users.getAvatar(req.params.identifier));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
res.set('Content-Type', 'image/png');
|
||||
res.send(avatar);
|
||||
if (avatar === constants.AVATAR_GRAVATAR) {
|
||||
superagent(gravatarUrl).pipe(`https://www.gravatar.com/avatar/${require('crypto').createHash('md5').update(user.email).digest('hex')}.jpg`);
|
||||
} else if (avatar === constants.AVATAR_NONE) {
|
||||
// res.set('Content-Type', 'image/png');
|
||||
// res.send(avatar);
|
||||
} else {
|
||||
res.set('Content-Type', 'image/png');
|
||||
res.send(avatar);
|
||||
}
|
||||
}
|
||||
|
||||
async function setBackgroundImage(req, res, next) {
|
||||
|
||||
Reference in New Issue
Block a user