aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc/persistent.lib.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2022-09-28 17:47:00 +0100
committerMatthew Wild <mwild1@gmail.com>2022-09-28 17:47:00 +0100
commit4dc941fa5370d86a0338587feb321693bcdabc9b (patch)
treee6f59605e02207c83d0c09fc5857c326c1df723a /plugins/muc/persistent.lib.lua
parent67db8995113b2772367fcd2cd6d471afd08b410c (diff)
downloadprosody-4dc941fa5370d86a0338587feb321693bcdabc9b.tar.gz
prosody-4dc941fa5370d86a0338587feb321693bcdabc9b.zip
muc: Re-allow non-admins to configure persistence (thanks Meaz)
Non-admins don't have a role on MUC services by default. Not even prosody:user. This meant they had no :create-persistent-room permission, even if muc_room_allow_persistent was true (the default). Now we only check the role permissions if persistent room creation is restricted, otherwise we skip any permission checks, just like previous versions.
Diffstat (limited to 'plugins/muc/persistent.lib.lua')
-rw-r--r--plugins/muc/persistent.lib.lua9
1 files changed, 3 insertions, 6 deletions
diff --git a/plugins/muc/persistent.lib.lua b/plugins/muc/persistent.lib.lua
index 4c753921..fc0f16db 100644
--- a/plugins/muc/persistent.lib.lua
+++ b/plugins/muc/persistent.lib.lua
@@ -8,10 +8,7 @@
--
local restrict_persistent = not module:get_option_boolean("muc_room_allow_persistent", true);
-module:default_permission(
- restrict_persistent and "prosody:admin" or "prosody:user",
- ":create-persistent-room"
-);
+module:default_permission("prosody:admin", ":create-persistent-room"); -- Admins can always create, by default
local function get_persistent(room)
return room._data.persistent;
@@ -25,7 +22,7 @@ local function set_persistent(room, persistent)
end
module:hook("muc-config-form", function(event)
- if not module:may(":create-persistent-room", event.actor) then
+ if restrict_persistent and not module:may(":create-persistent-room", event.actor) then
-- Hide config option if this user is not allowed to create persistent rooms
return;
end
@@ -39,7 +36,7 @@ module:hook("muc-config-form", function(event)
end, 100-5);
module:hook("muc-config-submitted/muc#roomconfig_persistentroom", function(event)
- if not module:may(":create-persistent-room", event.actor) then
+ if restrict_persistent and not module:may(":create-persistent-room", event.actor) then
return; -- Not allowed
end
if set_persistent(event.room, event.value) then