feat: Add ability to use Gravatar as avatar provider (#1319)

Closes #1243
This commit is contained in:
Mary Ojo
2025-09-05 18:00:17 +01:00
committed by GitHub
parent 37bd4d1349
commit 5dc783c5b5
7 changed files with 56 additions and 3 deletions

View File

@@ -0,0 +1,26 @@
/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
const crypto = require('crypto');
module.exports = {
sync: true,
inputs: {
record: {
type: 'ref',
required: true,
},
},
fn(inputs) {
if (!sails.config.custom.gravatarBaseUrl) {
return null;
}
const hash = crypto.createHash('md5').update(inputs.record.email).digest('hex');
return `${sails.config.custom.gravatarBaseUrl}${hash}?s=180&d=initials`;
},
};

View File

@@ -36,6 +36,12 @@ module.exports = {
termsType: sails.hooks.terms.getTypeByUserRole(inputs.record.role),
};
const gravatarUrl = sails.helpers.users.buildGravatarUrl(inputs.record);
if (gravatarUrl) {
data.gravatarUrl = gravatarUrl;
}
if (inputs.user) {
const isForCurrentUser = inputs.record.id === inputs.user.id;
const isForAdmin = inputs.user.role === User.Roles.ADMIN;