diff options
Diffstat (limited to 'slixmpp')
-rw-r--r-- | slixmpp/plugins/xep_0030/disco.py | 10 | ||||
-rw-r--r-- | slixmpp/plugins/xep_0363/http_upload.py | 19 |
2 files changed, 18 insertions, 11 deletions
diff --git a/slixmpp/plugins/xep_0030/disco.py b/slixmpp/plugins/xep_0030/disco.py index 460a9134..59b1e0cc 100644 --- a/slixmpp/plugins/xep_0030/disco.py +++ b/slixmpp/plugins/xep_0030/disco.py @@ -299,18 +299,18 @@ class XEP_0030(BasePlugin): return self.api['has_identity'](jid, node, ifrom, data) async def get_info_from_domain(self, domain=None, timeout=None, - cached=True, callback=None, **kwargs): + cached=True, callback=None): if domain is None: domain = self.xmpp.boundjid.domain if not cached or domain not in self.domain_infos: infos = [self.get_info( - domain, timeout=timeout, **kwargs)] + domain, timeout=timeout)] iq_items = await self.get_items( - domain, timeout=timeout, **kwargs) + domain, timeout=timeout) items = iq_items['disco_items']['items'] infos += [ - self.get_info(item[0], timeout=timeout, **kwargs) + self.get_info(item[0], timeout=timeout) for item in items] info_futures, _ = await asyncio.wait( infos, @@ -319,7 +319,7 @@ class XEP_0030(BasePlugin): ) self.domain_infos[domain] = [ - future.result() for future in info_futures] + future.result() for future in info_futures if not future.exception()] results = self.domain_infos[domain] diff --git a/slixmpp/plugins/xep_0363/http_upload.py b/slixmpp/plugins/xep_0363/http_upload.py index 65894975..2228ca8b 100644 --- a/slixmpp/plugins/xep_0363/http_upload.py +++ b/slixmpp/plugins/xep_0363/http_upload.py @@ -6,7 +6,6 @@ See the file LICENSE for copying permission. """ -import asyncio import logging import os.path @@ -68,12 +67,18 @@ class XEP_0363(BasePlugin): def _handle_request(self, iq): self.xmpp.event('http_upload_request', iq) - async def find_upload_service(self, timeout=None): - results = await self.xmpp['xep_0030'].get_info_from_domain() + async def find_upload_service(self, domain=None, timeout=None): + results = await self.xmpp['xep_0030'].get_info_from_domain( + domain=domain, timeout=timeout) + candidates = [] for info in results: for identity in info['disco_info']['identities']: if identity[0] == 'store' and identity[1] == 'file': + candidates.append(info) + for info in candidates: + for feature in info['disco_info']['features']: + if feature == Request.namespace: return info def request_slot(self, jid, filename, size, content_type=None, ifrom=None, @@ -90,11 +95,12 @@ class XEP_0363(BasePlugin): timeout_callback=timeout_callback) async def upload_file(self, filename, size=None, content_type=None, *, - input_file=None, ifrom=None, timeout=None, + input_file=None, ifrom=None, domain=None, timeout=None, callback=None, timeout_callback=None): ''' Helper function which does all of the uploading process. ''' if self.upload_service is None: - info_iq = await self.find_upload_service(timeout=timeout) + info_iq = await self.find_upload_service( + domain=domain, timeout=timeout) if info_iq is None: raise UploadServiceNotFound() self.upload_service = info_iq['from'] @@ -125,7 +131,8 @@ class XEP_0363(BasePlugin): basename = os.path.basename(filename) slot_iq = await self.request_slot(self.upload_service, basename, size, - content_type, ifrom, timeout) + content_type, ifrom, timeout, + timeout_callback=timeout_callback) slot = slot_iq['http_upload_slot'] headers = { |