3 var resolveUserAvatarUrl = require('gitter-web-shared/avatars/resolve-user-avatar-url');
4 var userService = require('gitter-web-users');
6 var DEFAULT_AVATAR_URL = 'https://avatars1.githubusercontent.com/u/0';
8 function resolveAvatarForUsername(req, res) {
9 var username = req.params.username;
10 var size = parseInt(req.query.s, 10) || 60;
12 return userService.findByUsername(username).then(function(user) {
15 url = resolveUserAvatarUrl(user, size);
16 if (url.indexOf('/api/private/user-avatar/') !== -1) {
17 // don't keep redirecting back here in a loop..
18 url = DEFAULT_AVATAR_URL;
21 url = DEFAULT_AVATAR_URL;
27 module.exports = resolveAvatarForUsername;