Changeset

12732:f731eda8a873

Backed out changeset 73a45ba6e3f1 in favour of 427dd01f0864 New behaviour (muc_room_allow_persistent = true, the default): - Parent host users are not restricted by default (prosody:user) - Users without roles (by default that is non-admins, non-parent-host users, and users on other servers) can no longer configure persistence by default. muc_room_allow_persistent = false will restrict persistence to prosody:admin. Parent-host users should not be restricted by default, and this can be configured via the new roles/permissions options.
author Matthew Wild <mwild1@gmail.com>
date Thu, 29 Sep 2022 12:43:09 +0100
parents 12731:a314f5bff9f0
children 12733:2167e1639aab
files plugins/muc/persistent.lib.lua
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/muc/persistent.lib.lua	Thu Sep 29 12:30:52 2022 +0100
+++ b/plugins/muc/persistent.lib.lua	Thu Sep 29 12:43:09 2022 +0100
@@ -8,7 +8,10 @@
 --
 
 local restrict_persistent = not module:get_option_boolean("muc_room_allow_persistent", true);
-module:default_permission("prosody:admin", ":create-persistent-room"); -- Admins can always create, by default
+module:default_permission(
+	restrict_persistent and "prosody:admin" or "prosody:user",
+	":create-persistent-room"
+);
 
 local function get_persistent(room)
 	return room._data.persistent;
@@ -22,7 +25,7 @@
 end
 
 module:hook("muc-config-form", function(event)
-	if restrict_persistent and not module:may(":create-persistent-room", event.actor) then
+	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
@@ -36,7 +39,7 @@
 end, 100-5);
 
 module:hook("muc-config-submitted/muc#roomconfig_persistentroom", function(event)
-	if restrict_persistent and not module:may(":create-persistent-room", event.actor) then
+	if not module:may(":create-persistent-room", event.actor) then
 		return; -- Not allowed
 	end
 	if set_persistent(event.room, event.value) then