Fixes a bug with avatar when no id or email is sent with presence.

This commit is contained in:
fo 2014-11-27 18:14:43 +02:00
parent 1d4177faeb
commit 1d0b4d0ecb
1 changed files with 6 additions and 3 deletions

View File

@ -14,7 +14,7 @@ var Avatar = (function(my) {
} }
users[jid] = id; users[jid] = id;
} }
var url = getGravatarUrl(users[jid]); var url = getGravatarUrl(users[jid] || jid);
var resourceJid = Strophe.getResourceFromJid(jid); var resourceJid = Strophe.getResourceFromJid(jid);
var thumbnail = $('#participant_' + resourceJid); var thumbnail = $('#participant_' + resourceJid);
var avatar = $('#avatar_' + resourceJid); var avatar = $('#avatar_' + resourceJid);
@ -128,9 +128,12 @@ var Avatar = (function(my) {
return mediaStreams[jid][MediaStream.VIDEO_TYPE].muted; return mediaStreams[jid][MediaStream.VIDEO_TYPE].muted;
} }
function getGravatarUrl(email, size) { function getGravatarUrl(id, size) {
if(id === connection.emuc.myroomjid) {
id = SettingsMenu.getUID();
}
return 'https://www.gravatar.com/avatar/' + return 'https://www.gravatar.com/avatar/' +
(email ? MD5.hexdigest(email.trim().toLowerCase()) : SettingsMenu.getUID()) + MD5.hexdigest(id.trim().toLowerCase()) +
"?d=retro&size=" + (size || "30"); "?d=retro&size=" + (size || "30");
} }