Fixes setting custom avatar based on the email and reverts the functionality to set custom avatar links to replace the default gravatars.
This commit is contained in:
parent
1702105b06
commit
01a9d47959
|
@ -1,4 +1,4 @@
|
||||||
/* global Strophe, APP, MD5, config */
|
/* global Strophe, APP, MD5, config, interfaceConfig */
|
||||||
var users = {};
|
var users = {};
|
||||||
|
|
||||||
var Avatar = {
|
var Avatar = {
|
||||||
|
@ -46,17 +46,27 @@ var Avatar = {
|
||||||
console.error("Get gravatar - id is undefined");
|
console.error("Get gravatar - id is undefined");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default to using gravatar.
|
||||||
|
var urlPref = 'https://www.gravatar.com/avatar/';
|
||||||
|
var urlSuf = "?d=wavatar&size=" + (size || "30");
|
||||||
|
|
||||||
|
// If we have a real email we will use it for the gravatar and we'll
|
||||||
|
// use the pre-configured URL if any. Otherwise, it's a random avatar.
|
||||||
var email = users[id];
|
var email = users[id];
|
||||||
if (!email) {
|
if (email && email.indexOf('@')) {
|
||||||
console.warn(
|
id = email;
|
||||||
"No avatar stored yet for " + id + " - using user id as ID"
|
|
||||||
);
|
if (interfaceConfig.RANDOM_AVATAR_URL_PREFIX) {
|
||||||
email = id;
|
urlPref = interfaceConfig.RANDOM_AVATAR_URL_PREFIX;
|
||||||
|
urlSuf = interfaceConfig.RANDOM_AVATAR_URL_SUFFIX;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.disableThirdPartyRequests) {
|
if (!config.disableThirdPartyRequests) {
|
||||||
return 'https://www.gravatar.com/avatar/' +
|
return urlPref +
|
||||||
MD5.hexdigest(id.trim().toLowerCase()) +
|
MD5.hexdigest(id.trim().toLowerCase()) +
|
||||||
"?d=wavatar&size=" + (size || "30");
|
urlSuf;
|
||||||
} else {
|
} else {
|
||||||
return 'images/avatar2.png';
|
return 'images/avatar2.png';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue