comparison sat/memory/disco.py @ 2587:e70023e84974

core (disco): fixed disco capabilities (empty disco was used)
author Goffi <goffi@goffi.org>
date Tue, 22 May 2018 09:59:58 +0200
parents 26edcf3a30eb
children 56f94936df1e
comparison
equal deleted inserted replaced
2586:57c8c155192f 2587:e70023e84974
82 82
83 def load(self): 83 def load(self):
84 def fillHashes(hashes): 84 def fillHashes(hashes):
85 for hash_, xml in hashes.iteritems(): 85 for hash_, xml in hashes.iteritems():
86 element = xml_tools.ElementParser()(xml) 86 element = xml_tools.ElementParser()(xml)
87 self.hashes[hash_] = disco.DiscoInfo.fromElement(element) 87 disco_info = disco.DiscoInfo.fromElement(element)
88 if not disco_info.features and not disco_info.identities:
89 log.warning(_(u"no feature/identity found in disco element (hash: {cap_hash}), ignoring: {xml}").format(
90 cap_hash=hash_, xml=xml))
91 else:
92 self.hashes[hash_] = disco_info
93
88 log.info(u"Disco hashes loaded") 94 log.info(u"Disco hashes loaded")
89 d = self.persistent.load() 95 d = self.persistent.load()
90 d.addCallback(fillHashes) 96 d.addCallback(fillHashes)
91 return d 97 return d
92 98
156 @return: a Deferred which fire disco.DiscoInfo 162 @return: a Deferred which fire disco.DiscoInfo
157 """ 163 """
158 if jid_ is None: 164 if jid_ is None:
159 jid_ = jid.JID(client.jid.host) 165 jid_ = jid.JID(client.jid.host)
160 try: 166 try:
161 cap_hash = self.host.memory.getEntityData(jid_, [C.ENTITY_CAP_HASH], client.profile)[C.ENTITY_CAP_HASH]
162 if not use_cache: 167 if not use_cache:
163 # we ignore cache, so we pretend we haven't found it 168 # we ignore cache, so we pretend we haven't found it
164 raise KeyError 169 raise KeyError
170 cap_hash = self.host.memory.getEntityData(jid_, [C.ENTITY_CAP_HASH], client.profile)[C.ENTITY_CAP_HASH]
165 except (KeyError, exceptions.UnknownEntityError): 171 except (KeyError, exceptions.UnknownEntityError):
166 # capability hash is not available, we'll compute one 172 # capability hash is not available, we'll compute one
167 def infosCb(disco_infos): 173 def infosCb(disco_infos):
168 cap_hash = self.generateHash(disco_infos) 174 cap_hash = self.generateHash(disco_infos)
169 self.hashes[cap_hash] = disco_infos 175 self.hashes[cap_hash] = disco_infos