Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
2af93f44
Commit
2af93f44
authored
Feb 22, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modtools: settings for which roles/affiliations may be queried or assigned
parent
e5341d54
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
141 additions
and
80 deletions
+141
-80
CHANGES.md
CHANGES.md
+2
-0
docs/source/configuration.rst
docs/source/configuration.rst
+20
-0
spec/modtools.js
spec/modtools.js
+2
-1
src/converse-muc-views.js
src/converse-muc-views.js
+37
-20
src/templates/moderator_tools_modal.js
src/templates/moderator_tools_modal.js
+78
-59
webpack.html
webpack.html
+2
-0
No files found.
CHANGES.md
View file @
2af93f44
...
...
@@ -18,6 +18,8 @@
-
#1839: Headline messages are shown in controlbox
-
Allow ignore bootstrap modules at build using environment variable: BOOTSTRAP_IGNORE_MODULES="Modal,Dropdown".
example: export BOOTSTRAP_IGNORE_MODULES="Modal,Dropdown" && make dist
-
New config option
[
modtools_disable_query
](
https://conversejs.org/docs/html/configuration.html#modtools-disable-query
)
-
New config option
[
modtools_disable_assign
](
https://conversejs.org/docs/html/configuration.html#modtools-disable-assign
)
## 6.0.0 (2020-01-09)
...
...
docs/source/configuration.rst
View file @
2af93f44
...
...
@@ -1039,6 +1039,26 @@ and it's trivial for an attacker to bypass this restriction.
You should therefore also configure your XMPP server to limit message sizes.
modtools_disable_assign
-----------------------
* Default: ``false``
* Possible Values: ``true``, ``false``, ``['owner', 'admin', 'member', 'outcast', 'none', 'moderator', 'participant', 'visitor']``
This setting allows you to disable (either completely, or fine-grained) which affiliations and or roles
may be assigned in the moderator tools modal.
modtools_disable_query
----------------------
* Default: ``[]``
* Possible Values: ``['owner', 'admin', 'member', 'outcast', 'none', 'moderator', 'participant', 'visitor']``
This setting allows you to disable which affiliations or roles may be queried in the moderator tools modal.
If all roles or all affiliations are disabled, then the relevant tab won't be
showed at all.
muc_disable_slash_commands
--------------------------
...
...
spec/modtools.js
View file @
2af93f44
...
...
@@ -41,7 +41,8 @@
_converse
.
connection
.
IQ_stanzas
=
[];
tab
.
click
();
let
select
=
modal
.
el
.
querySelector
(
'
.select-affiliation
'
);
expect
(
select
.
value
).
toBe
(
'
admin
'
);
expect
(
select
.
value
).
toBe
(
'
owner
'
);
select
.
value
=
'
admin
'
;
let
button
=
modal
.
el
.
querySelector
(
'
.btn-primary[name="users_with_affiliation"]
'
);
button
.
click
();
await
u
.
waitUntil
(()
=>
!
modal
.
loading_users_with_affiliation
);
...
...
src/converse-muc-views.js
View file @
2af93f44
...
...
@@ -40,7 +40,7 @@ const { Strophe, sizzle, $iq, $pres } = converse.env;
const
u
=
converse
.
env
.
utils
;
const
ROLES
=
[
'
moderator
'
,
'
participant
'
,
'
visitor
'
];
const
AFFILIATIONS
=
[
'
admin
'
,
'
member
'
,
'
outcast
'
,
'
owner
'
];
const
AFFILIATIONS
=
[
'
owner
'
,
'
admin
'
,
'
member
'
,
'
outcast
'
,
'
none
'
];
const
OWNER_COMMANDS
=
[
'
owner
'
];
const
ADMIN_COMMANDS
=
[
'
admin
'
,
'
ban
'
,
'
deop
'
,
'
destroy
'
,
'
member
'
,
'
op
'
,
'
revoke
'
];
const
MODERATOR_COMMANDS
=
[
'
kick
'
,
'
mute
'
,
'
voice
'
,
'
modtools
'
];
...
...
@@ -101,16 +101,18 @@ converse.plugins.add('converse-muc-views', {
'
auto_list_rooms
'
:
false
,
'
cache_muc_messages
'
:
true
,
'
locked_muc_nickname
'
:
false
,
'
show_retraction_warning
'
:
true
,
'
modtools_disable_query
'
:
[],
'
modtools_disable_assign
'
:
false
,
'
muc_disable_slash_commands
'
:
false
,
'
muc_show_join_leave
'
:
true
,
'
muc_show_join_leave_status
'
:
true
,
'
muc_mention_autocomplete_min_chars
'
:
0
,
'
muc_mention_autocomplete_filter
'
:
'
contains
'
,
'
muc_mention_autocomplete_min_chars
'
:
0
,
'
muc_mention_autocomplete_show_avatar
'
:
true
,
'
roomconfig_whitelist
'
:
[],
'
muc_roomid_policy
'
:
null
,
'
muc_roomid_policy_hint
'
:
null
,
'
muc_show_join_leave
'
:
true
,
'
muc_show_join_leave_status
'
:
true
,
'
roomconfig_whitelist
'
:
[],
'
show_retraction_warning
'
:
true
,
'
visible_toolbar_buttons
'
:
{
'
toggle_occupants
'
:
true
}
...
...
@@ -248,26 +250,17 @@ converse.plugins.add('converse-muc-views', {
},
toHTML
()
{
const
allowed_commands
=
this
.
chatroomview
.
getAllowedCommands
();
const
allowed_affiliations
=
allowed_commands
.
map
(
c
=>
COMMAND_TO_AFFILIATION
[
c
]).
filter
(
c
=>
c
);
const
allowed_roles
=
[...
new
Set
(
allowed_commands
.
filter
((
value
,
i
,
list
)
=>
list
.
indexOf
(
value
)
==
i
)
.
map
(
c
=>
COMMAND_TO_ROLE
[
c
])
.
filter
(
c
=>
c
))];
allowed_affiliations
.
sort
();
allowed_roles
.
sort
();
const
occupant
=
this
.
chatroomview
.
model
.
occupants
.
findWhere
({
'
jid
'
:
_converse
.
bare_jid
});
return
tpl_moderator_tools_modal
(
Object
.
assign
(
this
.
model
.
toJSON
(),
{
allowed_affiliations
,
allowed_roles
,
'
affiliations
'
:
[...
AFFILIATIONS
,
'
none
'
],
'
assignAffiliation
'
:
ev
=>
this
.
assignAffiliation
(
ev
),
'
assignRole
'
:
ev
=>
this
.
assignRole
(
ev
),
'
loading_users_with_affiliation
'
:
this
.
loading_users_with_affiliation
,
'
queryAffiliation
'
:
ev
=>
this
.
queryAffiliation
(
ev
),
'
queryRole
'
:
ev
=>
this
.
queryRole
(
ev
),
'
roles
'
:
ROLES
,
'
queryable_affiliations
'
:
AFFILIATIONS
.
filter
(
a
=>
!
_converse
.
modtools_disable_query
.
includes
(
a
)),
'
queryable_roles
'
:
ROLES
.
filter
(
a
=>
!
_converse
.
modtools_disable_query
.
includes
(
a
)),
'
assignable_affiliations
'
:
this
.
getAssignableAffiliations
(
occupant
),
'
assignable_roles
'
:
this
.
getAssignableRoles
(
occupant
),
'
switchTab
'
:
ev
=>
this
.
switchTab
(
ev
),
'
toggleForm
'
:
ev
=>
this
.
toggleForm
(
ev
),
'
users_with_affiliation
'
:
this
.
users_with_affiliation
,
...
...
@@ -275,6 +268,30 @@ converse.plugins.add('converse-muc-views', {
}));
},
getAssignableAffiliations
(
occupant
)
{
const
disabled
=
_converse
.
modtools_disable_assign
;
if
(
!
Array
.
isArray
(
disabled
))
{
return
disabled
?
[]
:
AFFILIATIONS
;
}
else
if
(
occupant
.
get
(
'
affiliation
'
)
===
'
owner
'
)
{
return
AFFILIATIONS
.
filter
(
a
=>
!
disabled
.
includes
(
a
));
}
else
if
(
occupant
.
get
(
'
affiliation
'
)
===
'
admin
'
)
{
return
AFFILIATIONS
.
filter
(
a
=>
!
[
'
owner
'
,
...
disabled
].
includes
(
a
));
}
else
{
return
[];
}
},
getAssignableRoles
(
occupant
)
{
const
disabled
=
_converse
.
modtools_disable_assign
;
if
(
!
Array
.
isArray
(
disabled
))
{
return
disabled
?
[]
:
ROLES
;
}
else
if
(
occupant
.
get
(
'
role
'
)
===
'
moderator
'
)
{
return
ROLES
.
filter
(
r
=>
!
disabled
.
includes
(
r
));
}
else
{
return
[];
}
},
shouldFetchAffiliationsList
()
{
const
affiliation
=
this
.
model
.
get
(
'
affiliation
'
);
if
(
affiliation
===
'
none
'
)
{
...
...
src/templates/moderator_tools_modal.js
View file @
2af93f44
This diff is collapsed.
Click to expand it.
webpack.html
View file @
2af93f44
...
...
@@ -23,6 +23,8 @@
auto_away
:
300
,
auto_register_muc_nickname
:
true
,
loglevel
:
'
debug
'
,
modtools_disable_assign
:
[
'
owner
'
,
'
moderator
'
,
'
participant
'
,
'
visitor
'
],
modtools_disable_query
:
[
'
moderator
'
,
'
participant
'
,
'
visitor
'
],
enable_smacks
:
true
,
i18n
:
'
en
'
,
message_archiving
:
'
always
'
,
...
...
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