aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc/persistent.lib.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2022-08-22 13:53:35 +0100
committerMatthew Wild <mwild1@gmail.com>2022-08-22 13:53:35 +0100
commite4ed9a570ab61ef45ca0e63dfd6d230e26812749 (patch)
tree361af05ddf1d012f9ce849528d36cfa83a0715ba /plugins/muc/persistent.lib.lua
parentb79cb49bfba1d64dda54cf7243154624c53b5fb9 (diff)
parent227f6c033697210a54f671f5b9128cde8699fdcd (diff)
downloadprosody-e4ed9a570ab61ef45ca0e63dfd6d230e26812749.tar.gz
prosody-e4ed9a570ab61ef45ca0e63dfd6d230e26812749.zip
Merge role-auth->trunk
Diffstat (limited to 'plugins/muc/persistent.lib.lua')
-rw-r--r--plugins/muc/persistent.lib.lua11
1 files changed, 7 insertions, 4 deletions
diff --git a/plugins/muc/persistent.lib.lua b/plugins/muc/persistent.lib.lua
index c3b16ea4..4c753921 100644
--- a/plugins/muc/persistent.lib.lua
+++ b/plugins/muc/persistent.lib.lua
@@ -8,7 +8,10 @@
--
local restrict_persistent = not module:get_option_boolean("muc_room_allow_persistent", true);
-local um_is_admin = require "core.usermanager".is_admin;
+module:default_permission(
+ restrict_persistent and "prosody:admin" or "prosody:user",
+ ":create-persistent-room"
+);
local function get_persistent(room)
return room._data.persistent;
@@ -22,8 +25,8 @@ 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
+ if not module:may(":create-persistent-room", event.actor) then
+ -- Hide config option if this user is not allowed to create persistent rooms
return;
end
table.insert(event.form, {
@@ -36,7 +39,7 @@ 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
+ if not module:may(":create-persistent-room", event.actor) then
return; -- Not allowed
end
if set_persistent(event.room, event.value) then