Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
gajim
python-nbxmpp
Commits
e3839b91
Commit
e3839b91
authored
Mar 06, 2021
by
Philipp Hörist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Blocking: Use JID and sets everywhere
parent
03bbb2fa
Pipeline
#7453
passed with stages
in 5 minutes and 5 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
nbxmpp/modules/blocking.py
nbxmpp/modules/blocking.py
+12
-6
nbxmpp/structs.py
nbxmpp/structs.py
+1
-1
No files found.
nbxmpp/modules/blocking.py
View file @
e3839b91
...
...
@@ -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
.
a
ppen
d
(
jid
)
jids
.
a
d
d
(
jid
)
block
,
unblock
=
[],
[]
block
,
unblock
=
set
(),
set
()
if
node
.
getName
()
==
'block'
:
block
=
jids
else
:
...
...
nbxmpp/structs.py
View file @
e3839b91
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment