diff options
Diffstat (limited to 'slixmpp/plugins')
-rw-r--r-- | slixmpp/plugins/xep_0030/disco.py | 16 | ||||
-rw-r--r-- | slixmpp/plugins/xep_0077/register.py | 2 | ||||
-rw-r--r-- | slixmpp/plugins/xep_0153/vcard_avatar.py | 5 | ||||
-rw-r--r-- | slixmpp/plugins/xep_0163.py | 10 | ||||
-rw-r--r-- | slixmpp/plugins/xep_0199/ping.py | 5 | ||||
-rw-r--r-- | slixmpp/plugins/xep_0223.py | 2 | ||||
-rw-r--r-- | slixmpp/plugins/xep_0363/http_upload.py | 25 |
7 files changed, 44 insertions, 21 deletions
diff --git a/slixmpp/plugins/xep_0030/disco.py b/slixmpp/plugins/xep_0030/disco.py index ea9a33f4..59b1e0cc 100644 --- a/slixmpp/plugins/xep_0030/disco.py +++ b/slixmpp/plugins/xep_0030/disco.py @@ -299,23 +299,27 @@ 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, timeout=timeout) + info_futures, _ = await asyncio.wait( + infos, + timeout=timeout, + loop=self.xmpp.loop + ) 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_0077/register.py b/slixmpp/plugins/xep_0077/register.py index 8c0c6f09..a7c6780f 100644 --- a/slixmpp/plugins/xep_0077/register.py +++ b/slixmpp/plugins/xep_0077/register.py @@ -59,7 +59,7 @@ class XEP_0077(BasePlugin): def _force_stream_feature(self, stanza): if isinstance(stanza, StreamFeatures): - if self.xmpp.use_tls or self.xmpp.use_ssl: + if not self.xmpp.disable_starttls: if 'starttls' not in self.xmpp.features: return stanza elif not isinstance(self.xmpp.socket, ssl.SSLSocket): diff --git a/slixmpp/plugins/xep_0153/vcard_avatar.py b/slixmpp/plugins/xep_0153/vcard_avatar.py index 6430e8d6..cf10283a 100644 --- a/slixmpp/plugins/xep_0153/vcard_avatar.py +++ b/slixmpp/plugins/xep_0153/vcard_avatar.py @@ -167,10 +167,7 @@ class XEP_0153(BasePlugin): data = pres['vcard_temp_update']['photo'] if data is None: return - elif data == '' or data != self.api['get_hash'](pres['from']): - ifrom = pres['to'] if self.xmpp.is_component else None - self.api['reset_hash'](pres['from'], ifrom=ifrom) - self.xmpp.event('vcard_avatar_update', pres) + self.xmpp.event('vcard_avatar_update', pres) # ================================================================= diff --git a/slixmpp/plugins/xep_0163.py b/slixmpp/plugins/xep_0163.py index 047ca5d3..4c302efa 100644 --- a/slixmpp/plugins/xep_0163.py +++ b/slixmpp/plugins/xep_0163.py @@ -62,7 +62,10 @@ class XEP_0163(BasePlugin): for ns in namespace: self.xmpp['xep_0030'].add_feature('%s+notify' % ns, jid=jid) - asyncio.ensure_future(self.xmpp['xep_0115'].update_caps(jid)) + asyncio.ensure_future( + self.xmpp['xep_0115'].update_caps(jid), + loop=self.xmpp.loop, + ) def remove_interest(self, namespace, jid=None): """ @@ -81,7 +84,10 @@ class XEP_0163(BasePlugin): for ns in namespace: self.xmpp['xep_0030'].del_feature(jid=jid, feature='%s+notify' % namespace) - asyncio.ensure_future(self.xmpp['xep_0115'].update_caps(jid)) + asyncio.ensure_future( + self.xmpp['xep_0115'].update_caps(jid), + loop=self.xmpp.loop, + ) def publish(self, stanza, node=None, id=None, options=None, ifrom=None, timeout_callback=None, callback=None, timeout=None): diff --git a/slixmpp/plugins/xep_0199/ping.py b/slixmpp/plugins/xep_0199/ping.py index 1153389b..f1070305 100644 --- a/slixmpp/plugins/xep_0199/ping.py +++ b/slixmpp/plugins/xep_0199/ping.py @@ -95,7 +95,10 @@ class XEP_0199(BasePlugin): self.timeout = timeout self.keepalive = True - handler = lambda event=None: asyncio.ensure_future(self._keepalive(event)) + handler = lambda event=None: asyncio.ensure_future( + self._keepalive(event), + loop=self.xmpp.loop, + ) self.xmpp.schedule('Ping keepalive', self.interval, handler, diff --git a/slixmpp/plugins/xep_0223.py b/slixmpp/plugins/xep_0223.py index 65d591f6..18875eee 100644 --- a/slixmpp/plugins/xep_0223.py +++ b/slixmpp/plugins/xep_0223.py @@ -26,7 +26,7 @@ class XEP_0223(BasePlugin): dependencies = {'xep_0163', 'xep_0060', 'xep_0004'} profile = {'pubsub#persist_items': True, - 'pubsub#send_last_published_item': 'never'} + 'pubsub#access_model': 'whitelist'} def configure(self, node, ifrom=None, callback=None, timeout=None): """ diff --git a/slixmpp/plugins/xep_0363/http_upload.py b/slixmpp/plugins/xep_0363/http_upload.py index 65894975..266fc656 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 @@ -31,6 +30,10 @@ class UploadServiceNotFound(FileUploadError): class FileTooBig(FileUploadError): pass +class HTTPError(FileUploadError): + def __str__(self): + return 'Could not upload file: %d (%s)' % (self.args[0], self.args[1]) + class XEP_0363(BasePlugin): ''' This plugin only supports Python 3.5+ ''' @@ -68,12 +71,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 +99,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 +135,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 = { @@ -141,6 +152,8 @@ class XEP_0363(BasePlugin): data=input_file, headers=headers, timeout=timeout) + if response.status >= 400: + raise HTTPError(response.status, await response.text()) log.info('Response code: %d (%s)', response.status, await response.text()) response.close() return slot['get']['url'] |