Changeset

10450:c1edeb9fe337

MUC: Indicate the component as origin of various errors where there's no room A room that doesn't exist can't return an error, can it?
author Kim Alvefur <zash@zash.se>
date Tue, 26 Nov 2019 00:02:13 +0100
parents 10449:2e36a54906e4
children 10451:347d16d70280
files plugins/muc/lock.lib.lua plugins/muc/mod_muc.lua
diffstat 2 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/muc/lock.lib.lua	Mon Nov 25 23:52:45 2019 +0100
+++ b/plugins/muc/lock.lib.lua	Tue Nov 26 00:02:13 2019 +0100
@@ -43,7 +43,7 @@
 module:hook("muc-occupant-pre-join", function(event)
 	if not event.is_new_room and is_locked(event.room) then -- Deny entry
 		module:log("debug", "Room is locked, denying entry");
-		event.origin.send(st.error_reply(event.stanza, "cancel", "item-not-found"));
+		event.origin.send(st.error_reply(event.stanza, "cancel", "item-not-found", nil, module.host));
 		return true;
 	end
 end, -30);
--- a/plugins/muc/mod_muc.lua	Mon Nov 25 23:52:45 2019 +0100
+++ b/plugins/muc/mod_muc.lua	Tue Nov 26 00:02:13 2019 +0100
@@ -355,7 +355,7 @@
 module:hook("muc-room-pre-create", function(event)
 	local origin, stanza = event.origin, event.stanza;
 	if not track_room(event.room) then
-		origin.send(st.error_reply(stanza, "wait", "resource-constraint"));
+		origin.send(st.error_reply(stanza, "wait", "resource-constraint", nil, module.host));
 		return true;
 	end
 end, -1000);
@@ -406,7 +406,7 @@
 				restrict_room_creation == "local" and
 				select(2, jid_split(user_jid)) == host_suffix
 			) then
-				origin.send(st.error_reply(stanza, "cancel", "not-allowed", "Room creation is restricted"));
+				origin.send(st.error_reply(stanza, "cancel", "not-allowed", "Room creation is restricted", module.host));
 				return true;
 			end
 		end);
@@ -451,7 +451,7 @@
 				room = nil;
 			else
 				if stanza.attr.type ~= "error" then
-					local reply = st.error_reply(stanza, "cancel", "gone", room._data.reason)
+					local reply = st.error_reply(stanza, "cancel", "gone", room._data.reason, module.host)
 					if room._data.newjid then
 						local uri = "xmpp:"..room._data.newjid.."?join";
 						reply:get_child("error"):child_with_name("gone"):text(uri);
@@ -465,20 +465,20 @@
 		if room == nil then
 			-- Watch presence to create rooms
 			if not jid_prep(room_jid, true) then
-				origin.send(st.error_reply(stanza, "modify", "jid-malformed"));
+				origin.send(st.error_reply(stanza, "modify", "jid-malformed", nil, module.host));
 				return true;
 			end
 			if stanza.attr.type == nil and stanza.name == "presence" and stanza:get_child("x", "http://jabber.org/protocol/muc") then
 				room = muclib.new_room(room_jid);
 				return room:handle_first_presence(origin, stanza);
 			elseif stanza.attr.type ~= "error" then
-				origin.send(st.error_reply(stanza, "cancel", "item-not-found"));
+				origin.send(st.error_reply(stanza, "cancel", "item-not-found", nil, module.host));
 				return true;
 			else
 				return;
 			end
 		elseif room == false then -- Error loading room
-			origin.send(st.error_reply(stanza, "wait", "resource-constraint"));
+			origin.send(st.error_reply(stanza, "wait", "resource-constraint", nil, module.host));
 			return true;
 		end
 		return room[method](room, origin, stanza);