Fix looking up local and cached vcards.
This commit is contained in:
parent
8a8926c5e8
commit
d3e8993e22
@ -55,17 +55,28 @@ class XEP_0054(BasePlugin):
|
|||||||
|
|
||||||
def get_vcard(self, jid=None, ifrom=None, local=False, cached=False,
|
def get_vcard(self, jid=None, ifrom=None, local=False, cached=False,
|
||||||
block=True, callback=None, timeout=None):
|
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
|
local = True
|
||||||
|
|
||||||
if local or cached:
|
if local:
|
||||||
vcard = self.api['get_vcard'](jid, None, ifrom)
|
vcard = self.api['get_vcard'](jid, None, ifrom)
|
||||||
if not isinstance(vcard, Iq):
|
if not isinstance(vcard, Iq):
|
||||||
iq = self.xmpp.Iq()
|
iq = self.xmpp.Iq()
|
||||||
|
if vcard is None:
|
||||||
|
vcard = VCardTemp()
|
||||||
iq.append(vcard)
|
iq.append(vcard)
|
||||||
return iq
|
return iq
|
||||||
return vcard
|
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 = self.xmpp.Iq()
|
||||||
iq['to'] = jid
|
iq['to'] = jid
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
@ -74,8 +85,9 @@ class XEP_0054(BasePlugin):
|
|||||||
|
|
||||||
vcard = iq.send(block=block, callback=callback, timeout=timeout)
|
vcard = iq.send(block=block, callback=callback, timeout=timeout)
|
||||||
|
|
||||||
self.api['set_vcard'](vcard['from'], args=vcard['vcard_temp'])
|
if block:
|
||||||
return vcard
|
self.api['set_vcard'](vcard['from'], args=vcard['vcard_temp'])
|
||||||
|
return vcard
|
||||||
|
|
||||||
def publish_vcard(self, vcard=None, jid=None, block=True, ifrom=None,
|
def publish_vcard(self, vcard=None, jid=None, block=True, ifrom=None,
|
||||||
callback=None, timeout=None):
|
callback=None, timeout=None):
|
||||||
@ -111,7 +123,7 @@ class XEP_0054(BasePlugin):
|
|||||||
self._vcard_cache[jid.bare] = vcard
|
self._vcard_cache[jid.bare] = vcard
|
||||||
|
|
||||||
def _get_vcard(self, jid, node, ifrom, 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):
|
def _del_vcard(self, jid, node, ifrom, vcard):
|
||||||
if jid.bare in self._vcard_cache:
|
if jid.bare in self._vcard_cache:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user