diff options
author | Matthew Wild <mwild1@gmail.com> | 2018-07-17 11:57:28 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2018-07-17 11:57:28 +0100 |
commit | 952f3697da404177715062bb8649db3b815ea8e9 (patch) | |
tree | b778b1a583eb31566b987dfa6f3dbc70a03629f0 /plugins/muc/hidden.lib.lua | |
parent | 057096d12b0da36a799b90d09120ccc0bd3174d0 (diff) | |
download | prosody-952f3697da404177715062bb8649db3b815ea8e9.tar.gz prosody-952f3697da404177715062bb8649db3b815ea8e9.zip |
MUC: Allow restricting public/persistent room options to service admins (muc_room_allow_public/muc_room_allow_persistent)
Diffstat (limited to 'plugins/muc/hidden.lib.lua')
-rw-r--r-- | plugins/muc/hidden.lib.lua | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/muc/hidden.lib.lua b/plugins/muc/hidden.lib.lua index acb8c0fc..153df21a 100644 --- a/plugins/muc/hidden.lib.lua +++ b/plugins/muc/hidden.lib.lua @@ -7,6 +7,9 @@ -- COPYING file in the source package for more information. -- +local restrict_public = not module:get_option_boolean("muc_room_allow_public", true); +local um_is_admin = require "core.usermanager".is_admin; + local function get_hidden(room) return room._data.hidden; end @@ -19,6 +22,10 @@ local function set_hidden(room, hidden) end module:hook("muc-config-form", function(event) + if restrict_public and not um_is_admin(event.actor, module.host) then + -- Don't show option if public rooms are restricted and user is not admin of this host + return; + end table.insert(event.form, { name = "muc#roomconfig_publicroom"; type = "boolean"; @@ -29,6 +36,9 @@ module:hook("muc-config-form", function(event) end, 100-9); module:hook("muc-config-submitted/muc#roomconfig_publicroom", function(event) + if restrict_public and not um_is_admin(event.actor, module.host) then + return; -- Not allowed + end if set_hidden(event.room, not event.value) then event.status_codes["104"] = true; end |