aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/muc/mod_muc.lua10
-rw-r--r--plugins/muc/muc.lib.lua16
2 files changed, 19 insertions, 7 deletions
diff --git a/plugins/muc/mod_muc.lua b/plugins/muc/mod_muc.lua
index 04846359..3b0d62ab 100644
--- a/plugins/muc/mod_muc.lua
+++ b/plugins/muc/mod_muc.lua
@@ -538,10 +538,14 @@ do -- Ad-hoc commands
end
return { status = "completed", error = { message = t_concat(errmsg, "\n") } };
end
- for _, room in ipairs(fields.rooms) do
- get_room_from_jid(room):destroy();
+ local destroyed = array();
+ for _, room_jid in ipairs(fields.rooms) do
+ local room = get_room_from_jid(room_jid);
+ if room and room:destroy() then
+ destroyed:push(room.jid);
+ end
end
- return { status = "completed", info = "The following rooms were destroyed:\n"..t_concat(fields.rooms, "\n") };
+ return { status = "completed", info = "The following rooms were destroyed:\n"..t_concat(destroyed, "\n") };
end);
local destroy_rooms_desc = adhoc_new("Destroy Rooms",
"http://prosody.im/protocol/muc#destroy", destroy_rooms_handler, "admin");
diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua
index 01704a36..c65ff9c7 100644
--- a/plugins/muc/muc.lib.lua
+++ b/plugins/muc/muc.lib.lua
@@ -1018,8 +1018,12 @@ function room_mt:clear(x)
end
function room_mt:destroy(newjid, reason, password)
- local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"})
- :tag("destroy", {jid=newjid});
+ local x = st.stanza("x", { xmlns = "http://jabber.org/protocol/muc#user" });
+ local event = { room = self; newjid = newjid; reason = reason; password = password; x = x, allowed = true };
+ module:fire_event("muc-pre-room-destroy", event);
+ if not event.allowed then return false, event.error; end
+ newjid, reason, password = event.newjid, event.reason, event.password;
+ x:tag("destroy", { jid = newjid });
if reason then x:tag("reason"):text(reason):up(); end
if password then x:tag("password"):text(password):up(); end
x:up();
@@ -1172,8 +1176,12 @@ function room_mt:handle_owner_query_set_to_room(origin, stanza)
local newjid = child.attr.jid;
local reason = child:get_child_text("reason");
local password = child:get_child_text("password");
- self:destroy(newjid, reason, password);
- origin.send(st.reply(stanza));
+ local destroyed, err = self:destroy(newjid, reason, password);
+ if destroyed then
+ origin.send(st.reply(stanza));
+ else
+ origin.send(st.error_reply(stanza, err or "cancel", "not-allowed"));
+ end
return true;
elseif child.name == "x" and child.attr.xmlns == "jabber:x:data" then
return self:process_form(origin, stanza);