From caae713dd63a045e28260df962e97e98fb1c0a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sun, 1 Jul 2018 01:36:26 +0100 Subject: xep_0030: rename find_identities; return all domain infos and let caller filter itself MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- slixmpp/plugins/xep_0030/disco.py | 10 +++------- slixmpp/plugins/xep_0363/http_upload.py | 9 ++++++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/slixmpp/plugins/xep_0030/disco.py b/slixmpp/plugins/xep_0030/disco.py index f16d36d2..ea9a33f4 100644 --- a/slixmpp/plugins/xep_0030/disco.py +++ b/slixmpp/plugins/xep_0030/disco.py @@ -298,8 +298,8 @@ class XEP_0030(BasePlugin): 'cached': cached} return self.api['has_identity'](jid, node, ifrom, data) - async def find_identities(category, type_, domain=None, timeout=None, - cached=True, callback=None, **kwargs): + async def get_info_from_domain(self, domain=None, timeout=None, + cached=True, callback=None, **kwargs): if domain is None: domain = self.xmpp.boundjid.domain @@ -317,11 +317,7 @@ class XEP_0030(BasePlugin): self.domain_infos[domain] = [ future.result() for future in info_futures] - results = [] - 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) + results = self.domain_infos[domain] if callback is not None: callback(results) diff --git a/slixmpp/plugins/xep_0363/http_upload.py b/slixmpp/plugins/xep_0363/http_upload.py index 3c0f2b3e..65894975 100644 --- a/slixmpp/plugins/xep_0363/http_upload.py +++ b/slixmpp/plugins/xep_0363/http_upload.py @@ -69,9 +69,12 @@ class XEP_0363(BasePlugin): self.xmpp.event('http_upload_request', iq) async def find_upload_service(self, timeout=None): - results = await self.xmpp['xep_0030'].find_identities('store', 'file') - if results: - return results[0] + results = await self.xmpp['xep_0030'].get_info_from_domain() + + 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, timeout=None, callback=None, timeout_callback=None): -- cgit v1.2.3