diff options
-rw-r--r-- | slixmpp/plugins/xep_0045.py | 2 | ||||
-rw-r--r-- | slixmpp/stanza/presence.py | 4 | ||||
-rw-r--r-- | slixmpp/xmlstream/xmlstream.py | 6 |
3 files changed, 7 insertions, 5 deletions
diff --git a/slixmpp/plugins/xep_0045.py b/slixmpp/plugins/xep_0045.py index 83521b01..30769b5c 100644 --- a/slixmpp/plugins/xep_0045.py +++ b/slixmpp/plugins/xep_0045.py @@ -162,7 +162,7 @@ class XEP_0045(BasePlugin): return self.xmpp.roster[pr['from']].ignore_updates = True entry = pr['muc'].get_stanza_values() - entry['show'] = pr['show'] + entry['show'] = pr['show'] if pr['show'] in pr.showtypes else None entry['status'] = pr['status'] entry['alt_nick'] = pr['nick'] if pr['type'] == 'unavailable': diff --git a/slixmpp/stanza/presence.py b/slixmpp/stanza/presence.py index 614cd331..7e59e1c5 100644 --- a/slixmpp/stanza/presence.py +++ b/slixmpp/stanza/presence.py @@ -90,10 +90,10 @@ class Presence(RootStanza): def get_type(self): """ Return the value of the <presence> stanza's type attribute, or - the value of the <show> element. + the value of the <show> element if valid. """ out = self._get_attr('type') - if not out: + if not out and self['show'] in self.showtypes: out = self['show'] if not out or out is None: out = 'available' diff --git a/slixmpp/xmlstream/xmlstream.py b/slixmpp/xmlstream/xmlstream.py index 17d23ff2..98b0744c 100644 --- a/slixmpp/xmlstream/xmlstream.py +++ b/slixmpp/xmlstream/xmlstream.py @@ -12,6 +12,8 @@ :license: MIT, see LICENSE for more details """ +from typing import Optional + import functools import logging import socket as Socket @@ -463,10 +465,10 @@ class XMLStream(asyncio.BaseProtocol): self._current_connection_attempt.cancel() self._current_connection_attempt = None - def disconnect(self, wait=2.0, reason=None): + def disconnect(self, wait: float = 2.0, reason: Optional[str] = None) -> None: """Close the XML stream and wait for an acknowldgement from the server for at most `wait` seconds. After the given number of seconds has - passed without a response from the serveur, or when the server + passed without a response from the server, or when the server successfully responds with a closure of its own stream, abort() is called. If wait is 0.0, this will call abort() directly without closing the stream. |