Diff

plugins/muc/muc.lib.lua @ 6216:50b8b7caf200

plugins/muc/muc.lib: Move occupancy check to later in `deconstruct_stanza_id`: As vcards are from the bare jid, you need to use the `from_jid` out of the encoded `id`
author daurnimator <quae@daurnimator.com>
date Thu, 03 Apr 2014 16:04:04 -0400
parent 6215:1dd09dc04945
child 6217:657c707d9229
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua	Thu Apr 03 15:14:52 2014 -0400
+++ b/plugins/muc/muc.lib.lua	Thu Apr 03 16:04:04 2014 -0400
@@ -622,13 +622,14 @@
 	local from, to = stanza.attr.from, stanza.attr.to;
 	local type = stanza.attr.type;
 	local id = stanza.attr.id;
-	local current_nick = self:get_occupant_jid(from);
 	local occupant = self:get_occupant_by_nick(to);
 	if (type == "error" or type == "result") then
 		do -- deconstruct_stanza_id
-			if not current_nick or not occupant then return nil; end
+			if not occupant then return nil; end
 			local from_jid, id, to_jid_hash = (base64.decode(stanza.attr.id) or ""):match("^(.+)%z(.*)%z(.+)$");
 			if not(from == from_jid or from == jid_bare(from_jid)) then return nil; end
+			local from_occupant_jid = self:get_occupant_jid(from_jid);
+			if from_occupant_jid == nil then return nil; end
 			local session_jid
 			for to_jid in occupant:each_session() do
 				if md5(to_jid) == to_jid_hash then
@@ -637,13 +638,14 @@
 				end
 			end
 			if session_jid == nil then return nil; end
-			stanza.attr.from, stanza.attr.to, stanza.attr.id = current_nick, session_jid, id
+			stanza.attr.from, stanza.attr.to, stanza.attr.id = from_jid, session_jid, id;
 		end
 		log("debug", "%s sent private iq stanza to %s (%s)", from, to, stanza.attr.to);
 		self:route_stanza(stanza);
 		stanza.attr.from, stanza.attr.to, stanza.attr.id = from, to, id;
 		return true;
 	else -- Type is "get" or "set"
+		local current_nick = self:get_occupant_jid(from);
 		if not current_nick then
 			origin.send(st.error_reply(stanza, "cancel", "not-acceptable"));
 			return true;