From f7bc1e99c0a5431581dabfaad9939b40d42b2a94 Mon Sep 17 00:00:00 2001 From: Daan Sprenkels Date: Sat, 22 Dec 2018 14:19:02 +0100 Subject: [PATCH] Remove blueimp-md5 dependency Signed-off-by: Daan Sprenkels --- lib/letter-avatars.js | 10 +++++++--- package.json | 1 - 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/letter-avatars.js b/lib/letter-avatars.js index 55cf9c3a3..7d463950f 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 } diff --git a/package.json b/package.json index 4fffa579d..cfea8953f 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,6 @@ "aws-sdk": "^2.345.0", "azure-storage": "^2.7.0", "base64url": "^3.0.0", - "blueimp-md5": "^2.6.0", "body-parser": "^1.15.2", "bootstrap": "^3.3.7", "bootstrap-validator": "^0.11.8",