2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
4 -- Copyright (C) 2014 Daurnimator
6 -- This project is MIT/X11 licensed. Please see the
7 -- COPYING file in the source package for more information.
10 local function get_moderated(room
)
11 return room
._data
.moderated
;
14 local function set_moderated(room
, moderated
)
15 moderated
= moderated
and true or nil;
16 if get_moderated(room
) == moderated
then return false; end
17 room
._data
.moderated
= moderated
;
21 module
:hook("muc-disco#info", function(event
)
22 event
.reply
:tag("feature", {var
= get_moderated(event
.room
) and "muc_moderated" or "muc_unmoderated"}):up();
25 module
:hook("muc-config-form", function(event
)
26 table.insert(event
.form
, {
27 name
= "muc#roomconfig_moderatedroom";
29 label
= "Moderated (require permission to speak)";
30 desc
= "In moderated rooms occupants must be given permission to speak by a room moderator";
31 value
= get_moderated(event
.room
);
35 module
:hook("muc-config-submitted/muc#roomconfig_moderatedroom", function(event
)
36 if set_moderated(event
.room
, event
.value
) then
37 event
.status_codes
["104"] = true;
41 module
:hook("muc-get-default-role", function(event
)
42 if event
.affiliation
== nil then
43 if get_moderated(event
.room
) then
45 -- An implementation MAY grant voice by default to visitors in unmoderated rooms.