plugin XEP-0115: fixed caps initial check
This commit is contained in:
parent
291127e677
commit
2422d0a1d7
1 changed files with 14 additions and 8 deletions
|
|
@ -56,14 +56,13 @@ class XEP_0115(object):
|
|||
def __init__(self, host):
|
||||
log.info(_("Plugin XEP_0115 initialization"))
|
||||
self.host = host
|
||||
host.trigger.add("Disco handled", self._checkHash)
|
||||
host.trigger.add("Presence send", self._presenceTrigger)
|
||||
|
||||
def getHandler(self, client):
|
||||
return XEP_0115_handler(self, client.profile)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def profileConnected(self, client):
|
||||
def _prepareCaps(self, client):
|
||||
# we have to calculate hash for client
|
||||
# because disco infos/identities may change between clients
|
||||
|
||||
|
|
@ -96,12 +95,18 @@ class XEP_0115(object):
|
|||
self.host.memory.disco.hashes[cap_hash] = disco_infos
|
||||
self.host.memory.updateEntityData(client.jid, C.ENTITY_CAP_HASH, cap_hash, profile_key=client.profile)
|
||||
|
||||
def _presenceTrigger(self, client, obj):
|
||||
def _presenceAddElt(self, client, obj):
|
||||
if client._caps_optimize:
|
||||
if client._caps_sent:
|
||||
return True
|
||||
return
|
||||
client.caps_sent = True
|
||||
obj.addChild(client._caps_elt)
|
||||
|
||||
def _presenceTrigger(self, client, obj, presence_d):
|
||||
if not hasattr(client, "_caps_optimize"):
|
||||
presence_d.addCallback(lambda __: self._prepareCaps(client))
|
||||
|
||||
presence_d.addCallback(lambda __: self._presenceAddElt(client, obj))
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue