diff --git a/src/plugins/plugin_xep_0054.py b/src/plugins/plugin_xep_0054.py index 705f0eb2..9e2fae9c 100755 --- a/src/plugins/plugin_xep_0054.py +++ b/src/plugins/plugin_xep_0054.py @@ -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