Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
poezio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
204
Issues
204
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poezio
poezio
Commits
9894e160
Commit
9894e160
authored
Feb 07, 2021
by
mathieui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
muctab: fix affiliation list command
parent
ab690bbd
Pipeline
#3663
passed with stages
in 5 minutes and 16 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
25 deletions
+20
-25
poezio/tabs/muctab.py
poezio/tabs/muctab.py
+20
-25
No files found.
poezio/tabs/muctab.py
View file @
9894e160
...
...
@@ -1677,21 +1677,25 @@ class MucTab(ChatTab):
self
.
change_affiliation
(
nick
,
affiliation
)
async
def
get_users_affiliations
(
self
,
jid
:
JID
)
->
None
:
MUC_ADMIN_NS
=
'http://jabber.org/protocol/muc#admin'
iqs
=
await
asyncio
.
gather
(
self
.
core
.
xmpp
[
'xep_0045'
].
get_users_by_affiliation
(
jid
,
'owner'
),
self
.
core
.
xmpp
[
'xep_0045'
].
get_users_by_affiliation
(
jid
,
'admin'
),
self
.
core
.
xmpp
[
'xep_0045'
].
get_users_by_affiliation
(
jid
,
'member'
),
self
.
core
.
xmpp
[
'xep_0045'
].
get_users_by_affiliation
(
jid
,
'outcast'
),
owners
,
admins
,
members
,
outcasts
=
await
asyncio
.
gather
(
self
.
core
.
xmpp
[
'xep_0045'
].
get_affiliation_list
(
jid
,
'owner'
),
self
.
core
.
xmpp
[
'xep_0045'
].
get_affiliation_list
(
jid
,
'admin'
),
self
.
core
.
xmpp
[
'xep_0045'
].
get_affiliation_list
(
jid
,
'member'
),
self
.
core
.
xmpp
[
'xep_0045'
].
get_affiliation_list
(
jid
,
'outcast'
),
return_exceptions
=
True
,
)
all_errors
=
functools
.
reduce
(
lambda
acc
,
iq
:
acc
and
isinstance
(
iq
,
(
IqError
,
IqTimeout
)),
iqs
,
(
owners
,
admins
,
members
,
outcasts
)
,
True
,
)
if
all_errors
:
self
.
core
.
information
(
'Can’t access affiliations for %s'
%
jid
.
bare
,
'Error'
,
)
return
None
theme
=
get_theme
()
aff_colors
=
{
...
...
@@ -1701,29 +1705,20 @@ class MucTab(ChatTab):
'outcast'
:
theme
.
CHAR_AFFILIATION_OUTCAST
,
}
if
all_errors
:
self
.
core
.
information
(
'Can’t access affiliations for %s'
%
jid
.
bare
,
'Error'
,
)
return
None
lines
=
[
'Affiliations for %s'
%
jid
.
bare
]
for
iq
in
iqs
:
if
isinstance
(
iq
,
BaseException
):
continue
query
=
iq
.
xml
.
find
(
'{%s}query'
%
MUC_ADMIN_NS
)
items
=
query
.
findall
(
'{%s}item'
%
MUC_ADMIN_NS
)
if
not
items
:
# Nobody with this affiliation
affiliation_dict
=
{
'owner'
:
owners
,
'admin'
:
admins
,
'member'
:
members
,
'outcast'
:
outcasts
,
}
for
affiliation
,
items
in
affiliation_dict
.
items
():
if
isinstance
(
items
,
BaseException
)
or
not
items
:
continue
affiliation
=
items
[
0
].
get
(
'affiliation'
)
aff_char
=
aff_colors
[
affiliation
]
lines
.
append
(
' %s%s'
%
(
aff_char
,
affiliation
.
capitalize
()))
items
=
map
(
lambda
i
:
i
.
get
(
'jid'
),
items
)
for
ajid
in
sorted
(
items
):
lines
.
append
(
' %s'
%
ajid
)
...
...
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