mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-23 03:27:05 -04:00
Allow to disable gravatar
Since Gravatar is an external image source and not perfect from a privacy perspective, forbidding it allows to improve privacy. This commit also simplifies and optimizes the avatar code. Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
This commit is contained in:
parent
a2608c319a
commit
318b2d378f
5 changed files with 23 additions and 27 deletions
|
@ -1,5 +1,6 @@
|
|||
'use strict'
|
||||
// external modules
|
||||
const md5 = require('blueimp-md5')
|
||||
const randomcolor = require('randomcolor')
|
||||
const config = require('./config')
|
||||
|
||||
|
@ -24,6 +25,17 @@ exports.generateAvatar = function (name) {
|
|||
return svg
|
||||
}
|
||||
|
||||
exports.generateAvatarURL = function (name) {
|
||||
return config.serverURL + '/user/' + name + '/avatar.svg'
|
||||
exports.generateAvatarURL = function (name, email = '', big = true) {
|
||||
let photo
|
||||
if (email !== '' && config.allowGravatar) {
|
||||
photo = 'https://www.gravatar.com/avatar/' + md5(email.toLowerCase())
|
||||
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'
|
||||
}
|
||||
return photo
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue