diff options
author | Lance Stout <lancestout@gmail.com> | 2012-04-08 16:01:21 -0400 |
---|---|---|
committer | Lance Stout <lancestout@gmail.com> | 2012-04-08 16:01:47 -0400 |
commit | d3e8993e22c46bccea37ab06b8fbc7abf97d959a (patch) | |
tree | aaed0a6452065ccd8bea036202ba5f0d08e92f6e /sleekxmpp/plugins | |
parent | 8a8926c5e80df922dbfc205c698a904e9ce30771 (diff) | |
download | slixmpp-d3e8993e22c46bccea37ab06b8fbc7abf97d959a.tar.gz slixmpp-d3e8993e22c46bccea37ab06b8fbc7abf97d959a.tar.bz2 slixmpp-d3e8993e22c46bccea37ab06b8fbc7abf97d959a.tar.xz slixmpp-d3e8993e22c46bccea37ab06b8fbc7abf97d959a.zip |
Fix looking up local and cached vcards.
Diffstat (limited to 'sleekxmpp/plugins')
-rw-r--r-- | sleekxmpp/plugins/xep_0054/vcard_temp.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/sleekxmpp/plugins/xep_0054/vcard_temp.py b/sleekxmpp/plugins/xep_0054/vcard_temp.py index 9be4c098..b9096759 100644 --- a/sleekxmpp/plugins/xep_0054/vcard_temp.py +++ b/sleekxmpp/plugins/xep_0054/vcard_temp.py @@ -55,17 +55,28 @@ class XEP_0054(BasePlugin): def get_vcard(self, jid=None, ifrom=None, local=False, cached=False, block=True, callback=None, timeout=None): - if self.xmpp.is_component and jid.bare == self.xmpp.boundjid.bare: + if self.xmpp.is_component and jid.domain == self.xmpp.boundjid.domain: local = True - if local or cached: + if local: vcard = self.api['get_vcard'](jid, None, ifrom) if not isinstance(vcard, Iq): iq = self.xmpp.Iq() + if vcard is None: + vcard = VCardTemp() iq.append(vcard) return iq return vcard + if cached: + vcard = self.api['get_vcard'](jid, None, ifrom) + if vcard is not None: + if not isinstance(vcard, Iq): + iq = self.xmpp.Iq() + iq.append(vcard) + return iq + return vcard + iq = self.xmpp.Iq() iq['to'] = jid iq['from'] = ifrom @@ -73,9 +84,10 @@ class XEP_0054(BasePlugin): iq.enable('vcard_temp') vcard = iq.send(block=block, callback=callback, timeout=timeout) - - self.api['set_vcard'](vcard['from'], args=vcard['vcard_temp']) - return vcard + + if block: + self.api['set_vcard'](vcard['from'], args=vcard['vcard_temp']) + return vcard def publish_vcard(self, vcard=None, jid=None, block=True, ifrom=None, callback=None, timeout=None): @@ -111,7 +123,7 @@ class XEP_0054(BasePlugin): self._vcard_cache[jid.bare] = vcard def _get_vcard(self, jid, node, ifrom, vcard): - return self._vcard_cache.get(jid.bare, VCardTemp()) + return self._vcard_cache.get(jid.bare, None) def _del_vcard(self, jid, node, ifrom, vcard): if jid.bare in self._vcard_cache: |