plugin XEP-0054: fixed presence issue when avatar is not in cache

This commit is contained in:
Goffi 2015-11-25 20:08:33 +01:00
commit 621f72ec1c

View file

@ -97,8 +97,13 @@ class XEP_0054(object):
def presenceAvailableTrigger(self, presence_elt, client):
if client.jid.userhost() in self.cache[client.profile]:
try:
avatar_hash = self.cache[client.profile][client.jid.userhost()]['avatar']
except KeyError:
log.info(u"No avatar in cache for {}".format(client.jid.userhost()))
return True
x_elt = domish.Element((NS_VCARD_UPDATE, 'x'))
x_elt.addElement('photo', content=self.cache[client.profile][client.jid.userhost()]['avatar'])
x_elt.addElement('photo', content=avatar_hash)
presence_elt.addChild(x_elt)
return True