# HG changeset patch
# User Matthew Wild <mwild1@gmail.com>
# Date 1699355438 0
# Node ID 939df56a51ba5a4402f0419c4372092b86b5e9b4
# Parent  852a61c720d0e96da3f4bea3416479f766883d32
mod_muc: Add :list-rooms permission

diff -r 852a61c720d0 -r 939df56a51ba plugins/muc/mod_muc.lua
--- a/plugins/muc/mod_muc.lua	Sun Nov 05 16:10:40 2023 +0100
+++ b/plugins/muc/mod_muc.lua	Tue Nov 07 11:10:38 2023 +0000
@@ -350,8 +350,12 @@
 end
 
 module:hook("host-disco-items", function(event)
+	module:log("debug", "host-disco-items called");
+	if not module:could(":list-rooms", event) then
+		module:log("debug", "Returning empty room list to unauthorized request");
+		return;
+	end
 	local reply = event.reply;
-	module:log("debug", "host-disco-items called");
 	if next(room_items_cache) ~= nil then
 		for jid, room_name in pairs(room_items_cache) do
 			if room_name == "" then room_name = nil; end