plugin XEP-0054: fixed presence issue when avatar is not in cache
This commit is contained in:
parent
9c4ec1595c
commit
621f72ec1c
1 changed files with 6 additions and 1 deletions
|
|
@ -97,8 +97,13 @@ class XEP_0054(object):
|
||||||
|
|
||||||
def presenceAvailableTrigger(self, presence_elt, client):
|
def presenceAvailableTrigger(self, presence_elt, client):
|
||||||
if client.jid.userhost() in self.cache[client.profile]:
|
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 = 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)
|
presence_elt.addChild(x_elt)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue