Use identicons as fallback for libravatar

The usage of identicons makes users more distinguishable as when only the default librvatar image is used.
This only applies to users that have no avatar on libravatar or gravatar.

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
Erik Michelson 2022-01-07 14:03:26 +01:00
parent 6e983ba5dc
commit d8faf3e342
No known key found for this signature in database
GPG key ID: DB99ADDDC5C0AF82

View file

@ -37,11 +37,11 @@ exports.generateAvatarURL = function (name, email = '', big = true) {
const hexDigest = hash.digest('hex') const hexDigest = hash.digest('hex')
if (email !== '' && config.allowGravatar) { if (email !== '' && config.allowGravatar) {
photo = 'https://cdn.libravatar.org/avatar/' + hexDigest photo = `https://cdn.libravatar.org/avatar/${hexDigest}?default=identicon`
if (big) { if (big) {
photo += '?s=400' photo += '&s=400'
} else { } else {
photo += '?s=96' photo += '&s=96'
} }
} else { } else {
photo = config.serverURL + '/user/' + (name || email.substring(0, email.lastIndexOf('@')) || hexDigest) + '/avatar.svg' photo = config.serverURL + '/user/' + (name || email.substring(0, email.lastIndexOf('@')) || hexDigest) + '/avatar.svg'