# HG changeset patch # User JC Brand # Date 1460728785 0 # Node ID 394a62163a91003697d91cc612805305e61297b2 # Parent 5e8dec076afc665691f1385139ba2103f9893278# Parent de3fb9d2673cc744b6cf155067716e3b2fe68165 Merge diff -r 5e8dec076afc -r 394a62163a91 mod_track_muc_joins/mod_track_muc_joins.lua --- 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?