From 35954cdc90f1f404c81b7ede47c2fae420e182e8 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Sat, 31 Dec 2011 19:18:00 -0500 Subject: [PATCH] Fix a few holes in caps. Protip: Don't test using a custom disco handler that always returns the same feature set :p --- sleekxmpp/plugins/xep_0115/caps.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/sleekxmpp/plugins/xep_0115/caps.py b/sleekxmpp/plugins/xep_0115/caps.py index 306629f6..db5b9bf3 100644 --- a/sleekxmpp/plugins/xep_0115/caps.py +++ b/sleekxmpp/plugins/xep_0115/caps.py @@ -245,14 +245,23 @@ class xep_0115(base_plugin): return base64.b64encode(binary) def update_caps(self, jid=None, node=None): - info = self.disco.get_info(jid, node, local=True) - if isinstance(info, Iq): - info = info['disco_info'] - ver = self.generate_verstring(info, self.hash) - self.cache_caps(ver, info) - self.assign_verstring(jid, ver) + try: + info = self.disco.get_info(jid, node, local=True) + if isinstance(info, Iq): + info = info['disco_info'] + ver = self.generate_verstring(info, self.hash) + self.disco.set_info( + jid=jid, + node='%s#%s' % (self.caps_node, ver), + info=info) + self.cache_caps(ver, info) + self.assign_verstring(jid, ver) + except XMPPError: + return def get_verstring(self, jid=None): + if jid in ('', None): + jid = self.xmpp.boundjid.full return self._run_node_handler('get_verstring', jid) def assign_verstring(self, jid=None, verstring=None):