diff options
author | Christoph (Sheogorath) Kern | 2019-01-05 14:08:23 +0100 |
---|---|---|
committer | GitHub | 2019-01-05 14:08:23 +0100 |
commit | 7a83fc0f14940ee5161ba1693d1bedc810b419c6 (patch) | |
tree | 4d2317c8038416c2032b0141849e4e23ba60edd5 /lib | |
parent | dba9575c94743a4efd65ff3db0d8748161ca13f0 (diff) | |
parent | f7bc1e99c0a5431581dabfaad9939b40d42b2a94 (diff) |
Merge pull request #1110 from dsprenkels/issue_1106
Remove blueimp-md5 dependency
Diffstat (limited to '')
-rw-r--r-- | lib/letter-avatars.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/letter-avatars.js b/lib/letter-avatars.js index 55cf9c3a..7d463950 100644 --- a/lib/letter-avatars.js +++ b/lib/letter-avatars.js @@ -1,6 +1,6 @@ 'use strict' // external modules -const md5 = require('blueimp-md5') +const crypto = require('crypto') const randomcolor = require('randomcolor') const config = require('./config') @@ -31,15 +31,19 @@ exports.generateAvatarURL = function (name, email = '', big = true) { email = '' + name + '@example.com' } + let hash = crypto.createHash('md5') + hash.update(email.toLowerCase()) + let hexDigest = hash.digest('hex') + if (email !== '' && config.allowGravatar) { - photo = 'https://www.gravatar.com/avatar/' + md5(email.toLowerCase()) + photo = 'https://www.gravatar.com/avatar/' + hexDigest; if (big) { photo += '?s=400' } else { photo += '?s=96' } } else { - photo = config.serverURL + '/user/' + (name || email.substring(0, email.lastIndexOf('@')) || md5(email.toLowerCase())) + '/avatar.svg' + photo = config.serverURL + '/user/' + (name || email.substring(0, email.lastIndexOf('@')) || hexDigest) + '/avatar.svg' } return photo } |