changeset 2160:394a62163a91

Merge
author JC Brand <jc@opkode.com>
date Fri, 15 Apr 2016 13:59:45 +0000
parents 5e8dec076afc (current diff) de3fb9d2673c (diff)
children 95a9f2d234da
files
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mod_track_muc_joins/mod_track_muc_joins.lua	Fri Apr 15 13:45:01 2016 +0000
+++ b/mod_track_muc_joins/mod_track_muc_joins.lua	Fri Apr 15 13:59:45 2016 +0000
@@ -6,10 +6,12 @@
 	local session = sessions[stanza.attr.to];
 	if not session then return end;
 	local log = session.log or module._log;
+
 	local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc#user");
 	if not muc_x then return end -- Not MUC related
 
-	local room = jid_bare(stanza.attr.from);
+	local from_jid = stanza.attr.from;
+	local room = jid_bare(from_jid);
 	local joined = stanza.attr.type;
 	if joined == nil then
 		joined = true;
@@ -20,6 +22,10 @@
 		return;
 	end
 
+	if joined and not session.directed or not session.directed[from_jid] then
+		return; -- Never sent presence there, can't be a MUC join
+	end
+
 	-- Check for status code 100, meaning it's their own reflected presence
 	for status in muc_x:childtags("status") do
 		log("debug", "Status code %d", status.attr.code);
@@ -27,6 +33,7 @@
 			log("debug", "%s room %s", joined and "Joined" or "Left", room);
 			local rooms = session.rooms_joined;
 			if not rooms then
+				if not joined then return; end
 				session.rooms_joined = { [room] = joined };
 			else
 				rooms[room] = joined;
@@ -36,4 +43,3 @@
 	end
 end);
 
--- TODO Check session.directed for outgoing presence?