changeset 2156:3fcac143fe0b

mod_track_muc_joins: Check directed presence
author Kim Alvefur <zash@zash.se>
date Tue, 12 Apr 2016 16:05:21 +0200
parents f24b02e0d706
children 7d1a22ac2a21
files mod_track_muc_joins/mod_track_muc_joins.lua
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mod_track_muc_joins/mod_track_muc_joins.lua	Sun Apr 03 17:09:03 2016 +0200
+++ b/mod_track_muc_joins/mod_track_muc_joins.lua	Tue Apr 12 16:05:21 2016 +0200
@@ -6,10 +6,16 @@
 	local session = sessions[stanza.attr.to];
 	if not session then return end;
 	local log = session.log or module._log;
+
+	local from_jid = stanza.attr.from;
+	if not session.directed or not session.directed[from_jid] then
+		return; -- Never sent presence there, can't be a MUC join
+	end
+
 	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 room = jid_bare(from_jid);
 	local joined = stanza.attr.type;
 	if joined == nil then
 		joined = true;
@@ -36,4 +42,3 @@
 	end
 end);
 
--- TODO Check session.directed for outgoing presence?