Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits: e3839b91 by lovetox at 2021-03-06T20:54:23+01:00 Blocking: Use JID and sets everywhere - - - - - 2 changed files: - nbxmpp/modules/blocking.py - nbxmpp/structs.py Changes: ===================================== nbxmpp/modules/blocking.py ===================================== @@ -52,9 +52,15 @@ class Blocking(BaseModule): if blocklist is None: raise MalformedStanzaError('blocklist node missing', result) - blocked = [] + blocked = set() for item in blocklist.getTags('item'): - blocked.append(item.getAttr('jid')) + try: + jid = JID.from_string(item.getAttr('jid')) + except Exception: + self._log.info('Invalid JID: %s', item.getAttr('jid')) + continue + + blocked.add(jid) self._log.info('Received blocking list: %s', blocked) yield blocked @@ -121,9 +127,9 @@ def _make_unblock_request(jids): def _parse_push(node): items = node.getTags('item') if not items: - return BlockingPush(block=[], unblock=[], unblock_all=True) + return BlockingPush(block=set(), unblock=set(), unblock_all=True) - jids = [] + jids = set() for item in items: jid = item.getAttr('jid') if not jid: @@ -134,10 +140,10 @@ def _parse_push(node): except Exception: continue - jids.append(jid) + jids.add(jid) - block, unblock = [], [] + block, unblock = set(), set() if node.getName() == 'block': block = jids else: ===================================== nbxmpp/structs.py ===================================== @@ -156,7 +156,7 @@ class RosterItem: attrs['jid'] = jid groups = {group.getData() for group in node.getTags('group')} - attrs['groups'] = set(groups) + attrs['groups'] = groups return cls(**attrs) View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/-/commit/e3839b9174c97480e7808fb030589e3ad4fd8331 -- View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/-/commit/e3839b9174c97480e7808fb030589e3ad4fd8331 You're receiving this email because of your account on dev.gajim.org.
_______________________________________________ Commits mailing list Commits@gajim.org https://lists.gajim.org/cgi-bin/listinfo/commits