diff options
author | Philipp Hörist <philipp@hoerist.com> | 2019-02-25 00:20:05 +0300 |
---|---|---|
committer | Philipp Hörist <philipp@hoerist.com> | 2019-02-25 00:20:05 +0300 |
commit | f37f2c9dfdbcb6f6fd5f9bd00c2b790f08c3119e (patch) | |
tree | eb9500623752fd4a8167c9f907e7e37678df53e3 /nbxmpp/modules | |
parent | 1abe1eab36b389bf2138ef894873b1f3b8a28860 (diff) |
Delay: Improve discovering server added delays
Diffstat (limited to 'nbxmpp/modules')
-rw-r--r-- | nbxmpp/modules/delay.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/nbxmpp/modules/delay.py b/nbxmpp/modules/delay.py index 1b05aed..526b492 100644 --- a/nbxmpp/modules/delay.py +++ b/nbxmpp/modules/delay.py @@ -44,16 +44,21 @@ class Delay: # to indicate when the user has set the subject, # the 'from' attr on these delays is the MUC server # but we treat it as user timestamp - properties.user_timestamp = parse_delay( - stanza, from_=properties.jid.getBare()) + jids = [properties.jid.getBare(), + properties.jid.getDomain()] + + properties.user_timestamp = parse_delay(stanza, from_=jids) else: - jid = self._client.get_bound_jid().getDomain() - timestamp = parse_delay(stanza, from_=jid) - if timestamp is not None: - properties.timestamp = timestamp + if properties.from_muc: + # Some servers use the MUC JID, others the domain + jids = [properties.jid.getBare(), + properties.jid.getDomain()] + else: + jids = [self._client.get_bound_jid().getDomain()] - properties.user_timestamp = parse_delay(stanza, not_from=[jid]) + properties.timestamp = parse_delay(stanza, from_=jids) + properties.user_timestamp = parse_delay(stanza, not_from=jids) @staticmethod def _process_presence_delay(_con, stanza, properties): @@ -85,7 +90,7 @@ def parse_delay(stanza, epoch=True, convert='utc', from_=None, not_from=None): delay_from = delay.getAttr('from') if from_ is not None: - if delay_from != from_: + if delay_from not in from_: continue if not_from is not None: if delay_from in not_from: |