diff options
author | mathieui <mathieui@mathieui.net> | 2021-04-12 20:43:42 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2021-04-12 20:43:51 +0200 |
commit | fc1eca7ac39bfc0dc82b2809b19b3d1c7b64a2c7 (patch) | |
tree | 43c1e991617df5d981f2c9a704ae0732818c0a16 /poezio/roster.py | |
parent | e6510792b4d4dcb0d9e7746fff0dd891cba33e3a (diff) | |
download | poezio-fc1eca7ac39bfc0dc82b2809b19b3d1c7b64a2c7.tar.gz poezio-fc1eca7ac39bfc0dc82b2809b19b3d1c7b64a2c7.tar.bz2 poezio-fc1eca7ac39bfc0dc82b2809b19b3d1c7b64a2c7.tar.xz poezio-fc1eca7ac39bfc0dc82b2809b19b3d1c7b64a2c7.zip |
fix: remove all remaining safejids (fix #3457)
Diffstat (limited to 'poezio/roster.py')
-rw-r--r-- | poezio/roster.py | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/poezio/roster.py b/poezio/roster.py index 86fc704c..4534dd30 100644 --- a/poezio/roster.py +++ b/poezio/roster.py @@ -8,7 +8,6 @@ Defines the Roster and RosterGroup classes """ import logging -log = logging.getLogger(__name__) from typing import List @@ -18,10 +17,10 @@ from poezio.roster_sorting import SORTING_METHODS, GROUP_SORTING_METHODS from os import path as p from datetime import datetime -from poezio.common import safeJID from slixmpp.exceptions import IqError, IqTimeout -from slixmpp import JID +from slixmpp import JID, InvalidJID +log = logging.getLogger(__name__) class Roster: """ @@ -77,7 +76,10 @@ class Roster: def __getitem__(self, key): """Get a Contact from his bare JID""" - key = safeJID(key).bare + try: + key = JID(key).bare + except InvalidJID: + return None if key in self.contacts and self.contacts[key] is not None: return self.contacts[key] if key in self.jids(): @@ -91,7 +93,10 @@ class Roster: def remove(self, jid): """Send a removal iq to the server""" - jid = safeJID(jid).bare + try: + jid = JID(jid).bare + except InvalidJID: + return if self.__node[jid]: try: self.__node[jid].send_presence(ptype='unavailable') @@ -101,7 +106,10 @@ class Roster: def __delitem__(self, jid): """Remove a contact from the roster view""" - jid = safeJID(jid).bare + try: + jid = JID(jid).bare + except InvalidJID: + return contact = self[jid] if not contact: return @@ -119,7 +127,10 @@ class Roster: def __contains__(self, key): """True if the bare jid is in the roster, false otherwise""" - return safeJID(key).bare in self.jids() + try: + return JID(key).bare in self.jids() + except InvalidJID: + return False @property def jid(self): |