From 621f72ec1c1a6d2d287175dccd2e7bd6f67e5f33 Mon Sep 17 00:00:00 2001 From: Goffi Date: Wed, 25 Nov 2015 20:08:33 +0100 Subject: [PATCH] plugin XEP-0054: fixed presence issue when avatar is not in cache --- src/plugins/plugin_xep_0054.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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