xep_0030: rename find_identities; return all domain infos and let caller filter itself
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
df0198abfe
commit
caae713dd6
@ -298,8 +298,8 @@ class XEP_0030(BasePlugin):
|
|||||||
'cached': cached}
|
'cached': cached}
|
||||||
return self.api['has_identity'](jid, node, ifrom, data)
|
return self.api['has_identity'](jid, node, ifrom, data)
|
||||||
|
|
||||||
async def find_identities(category, type_, domain=None, timeout=None,
|
async def get_info_from_domain(self, domain=None, timeout=None,
|
||||||
cached=True, callback=None, **kwargs):
|
cached=True, callback=None, **kwargs):
|
||||||
if domain is None:
|
if domain is None:
|
||||||
domain = self.xmpp.boundjid.domain
|
domain = self.xmpp.boundjid.domain
|
||||||
|
|
||||||
@ -317,11 +317,7 @@ class XEP_0030(BasePlugin):
|
|||||||
self.domain_infos[domain] = [
|
self.domain_infos[domain] = [
|
||||||
future.result() for future in info_futures]
|
future.result() for future in info_futures]
|
||||||
|
|
||||||
results = []
|
results = self.domain_infos[domain]
|
||||||
for info in self.domain_infos[domain]:
|
|
||||||
for identity in info['disco_info']['identities']:
|
|
||||||
if identity[0] == category and identity[1] == type_:
|
|
||||||
results.append(info)
|
|
||||||
|
|
||||||
if callback is not None:
|
if callback is not None:
|
||||||
callback(results)
|
callback(results)
|
||||||
|
@ -69,9 +69,12 @@ class XEP_0363(BasePlugin):
|
|||||||
self.xmpp.event('http_upload_request', iq)
|
self.xmpp.event('http_upload_request', iq)
|
||||||
|
|
||||||
async def find_upload_service(self, timeout=None):
|
async def find_upload_service(self, timeout=None):
|
||||||
results = await self.xmpp['xep_0030'].find_identities('store', 'file')
|
results = await self.xmpp['xep_0030'].get_info_from_domain()
|
||||||
if results:
|
|
||||||
return results[0]
|
for info in results:
|
||||||
|
for identity in info['disco_info']['identities']:
|
||||||
|
if identity[0] == 'store' and identity[1] == 'file':
|
||||||
|
return info
|
||||||
|
|
||||||
def request_slot(self, jid, filename, size, content_type=None, ifrom=None,
|
def request_slot(self, jid, filename, size, content_type=None, ifrom=None,
|
||||||
timeout=None, callback=None, timeout_callback=None):
|
timeout=None, callback=None, timeout_callback=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user