overleaf/services/chat/app/coffee/Features/Users/UserFormatter.coffee
2014-08-15 10:50:36 +01:00

18 lines
487 B
CoffeeScript

crypto = require "crypto"
module.exports = UserFormatter =
formatUserForClientSide: (user) ->
if user._id?
user.id = user._id.toString()
delete user._id
return {
id: user.id
first_name: user.first_name
last_name: user.last_name
email: user.email
gravatar_url: @_getGravatarUrlForEmail(user.email)
}
_getGravatarUrlForEmail: (email) ->
hash = crypto.createHash("md5").update(email.toLowerCase()).digest("hex")
return "//www.gravatar.com/avatar/#{hash}"