summaryrefslogtreecommitdiff
path: root/src/fixes.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-05-15 23:33:51 +0200
committermathieui <mathieui@mathieui.net>2014-05-15 23:33:51 +0200
commit97ef9d7fb90fd4a3a408868f0aa996728ad382cd (patch)
treec901a77993ae90c758cbb915b14c1da36edd975b /src/fixes.py
parent916416a019c398a484b6a436ee908808780263f9 (diff)
downloadpoezio-97ef9d7fb90fd4a3a408868f0aa996728ad382cd.tar.gz
poezio-97ef9d7fb90fd4a3a408868f0aa996728ad382cd.tar.bz2
poezio-97ef9d7fb90fd4a3a408868f0aa996728ad382cd.tar.xz
poezio-97ef9d7fb90fd4a3a408868f0aa996728ad382cd.zip
Make detecting the features supported by the remote entity less awful
no more stalling while waiting for a disco info while sending a message.
Diffstat (limited to 'src/fixes.py')
-rw-r--r--src/fixes.py97
1 files changed, 3 insertions, 94 deletions
diff --git a/src/fixes.py b/src/fixes.py
index cb992e88..18c117d8 100644
--- a/src/fixes.py
+++ b/src/fixes.py
@@ -10,10 +10,6 @@ from sleekxmpp.xmlstream import ET
import logging
-# used to avoid doing numerous useless disco#info requests
-# especially with message receipts
-IQ_ERRORS = set()
-
log = logging.getLogger(__name__)
def has_identity(xmpp, jid, identity):
@@ -91,97 +87,10 @@ def _filter_add_receipt_request(self, stanza):
if not stanza['body']:
return stanza
- if stanza['to'].resource:
- if not self.xmpp['xep_0030'].supports(stanza['to'],
- feature='urn:xmpp:receipts',
- cached=True):
- return stanza
+ # hack
+ if stanza['to'].resource and not hasattr(stanza, '_add_receipt'):
+ return stanza
stanza['request_receipt'] = True
return stanza
-def xep_30_supports(self, jid, node, ifrom, data):
- """
- Check if a JID supports a given feature.
-
- The data parameter may provide:
- feature -- The feature to check for support.
- local -- If true, then the query is for a JID/node
- combination handled by this Sleek instance and
- no stanzas need to be sent.
- Otherwise, a disco stanza must be sent to the
- remove JID to retrieve the info.
- cached -- If true, then look for the disco info data from
- the local cache system. If no results are found,
- send the query as usual. The self.use_cache
- setting must be set to true for this option to
- be useful. If set to false, then the cache will
- be skipped, even if a result has already been
- cached. Defaults to false.
- """
- feature = data.get('feature', None)
-
- data = {'local': data.get('local', False),
- 'cached': data.get('cached', True)}
-
- if not feature or jid.full in IQ_ERRORS:
- return False
-
- try:
- info = self.disco.get_info(jid=jid, node=node,
- ifrom=ifrom, **data)
- info = self.disco._wrap(ifrom, jid, info, True)
- features = info['disco_info']['features']
- return feature in features
- except:
- IQ_ERRORS.add(jid.full)
- log.debug('%s added to the list of entities that do'
- 'not honor disco#info', jid.full)
- return False
-
-def xep_115_supports(self, jid, node, ifrom, data):
- """
- Check if a JID supports a given feature.
-
- The data parameter may provide:
- feature -- The feature to check for support.
- local -- If true, then the query is for a JID/node
- combination handled by this Sleek instance and
- no stanzas need to be sent.
- Otherwise, a disco stanza must be sent to the
- remove JID to retrieve the info.
- cached -- If true, then look for the disco info data from
- the local cache system. If no results are found,
- send the query as usual. The self.use_cache
- setting must be set to true for this option to
- be useful. If set to false, then the cache will
- be skipped, even if a result has already been
- cached. Defaults to false.
- """
- feature = data.get('feature', None)
-
- data = {'local': data.get('local', False),
- 'cached': data.get('cached', True)}
-
- if not feature or jid.full in IQ_ERRORS:
- return False
-
- if node in (None, ''):
- info = self.caps.get_caps(jid)
- if info and feature in info['features']:
- return True
-
- try:
- info = self.disco.get_info(jid=jid, node=node,
- ifrom=ifrom, **data)
- info = self.disco._wrap(ifrom, jid, info, True)
- return feature in info['disco_info']['features']
- except:
- IQ_ERRORS.add(jid.full)
- log.debug('%s added to the list of entities that do'
- 'not honor disco#info', jid.full)
- return False
-
-def reset_iq_errors():
- "reset the iq error cache"
- IQ_ERRORS.clear()