aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc/persistent.lib.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-07-17 11:57:28 +0100
committerMatthew Wild <mwild1@gmail.com>2018-07-17 11:57:28 +0100
commitef2782cb25c435633a8d315652047ca1bb191f13 (patch)
treeb778b1a583eb31566b987dfa6f3dbc70a03629f0 /plugins/muc/persistent.lib.lua
parent999ee9e30bb5ee13b16fb8823190264373d38ca2 (diff)
downloadprosody-ef2782cb25c435633a8d315652047ca1bb191f13.tar.gz
prosody-ef2782cb25c435633a8d315652047ca1bb191f13.zip
MUC: Allow restricting public/persistent room options to service admins (muc_room_allow_public/muc_room_allow_persistent)
Diffstat (limited to 'plugins/muc/persistent.lib.lua')
-rw-r--r--plugins/muc/persistent.lib.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/muc/persistent.lib.lua b/plugins/muc/persistent.lib.lua
index aa2cdf26..c3b16ea4 100644
--- a/plugins/muc/persistent.lib.lua
+++ b/plugins/muc/persistent.lib.lua
@@ -7,6 +7,9 @@
-- COPYING file in the source package for more information.
--
+local restrict_persistent = not module:get_option_boolean("muc_room_allow_persistent", true);
+local um_is_admin = require "core.usermanager".is_admin;
+
local function get_persistent(room)
return room._data.persistent;
end
@@ -19,6 +22,10 @@ local function set_persistent(room, persistent)
end
module:hook("muc-config-form", function(event)
+ if restrict_persistent and not um_is_admin(event.actor, module.host) then
+ -- Don't show option if hidden rooms are restricted and user is not admin of this host
+ return;
+ end
table.insert(event.form, {
name = "muc#roomconfig_persistentroom";
type = "boolean";
@@ -29,6 +36,9 @@ module:hook("muc-config-form", function(event)
end, 100-5);
module:hook("muc-config-submitted/muc#roomconfig_persistentroom", function(event)
+ if restrict_persistent and not um_is_admin(event.actor, module.host) then
+ return; -- Not allowed
+ end
if set_persistent(event.room, event.value) then
event.status_codes["104"] = true;
end