Commit e3839b91 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Blocking: Use JID and sets everywhere

parent 03bbb2fa
Pipeline #7453 passed with stages
in 5 minutes and 5 seconds
......@@ -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:
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment