comparison mod_track_muc_joins/mod_track_muc_joins.lua @ 2335:eb456fd639d2

mod_track_muc_joins: Check if the map of directed presence exists earlier (fixes traceback due to precedence error) (thanks Link Mauve)
author Kim Alvefur <zash@zash.se>
date Sat, 15 Oct 2016 21:16:43 +0200
parents 12249570352f
children 443d9dae3216
comparison
equal deleted inserted replaced
2334:c728b2f77c7c 2335:eb456fd639d2
4 4
5 module:hook("presence/full", function (event) 5 module:hook("presence/full", function (event)
6 local stanza = event.stanza; 6 local stanza = event.stanza;
7 local session = sessions[stanza.attr.to]; 7 local session = sessions[stanza.attr.to];
8 if not session then return end; 8 if not session then return end;
9 if not session.directed then return end -- hasn't sent presence yet
9 local log = session.log or module._log; 10 local log = session.log or module._log;
10 11
11 local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc#user"); 12 local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc#user");
12 if not muc_x then return end -- Not MUC related 13 if not muc_x then return end -- Not MUC related
13 14
22 else 23 else
23 -- Ignore errors and whatever 24 -- Ignore errors and whatever
24 return; 25 return;
25 end 26 end
26 27
27 if joined and not session.directed or not session.directed[from_jid] then 28 if joined and not session.directed[from_jid] then
28 return; -- Never sent presence there, can't be a MUC join 29 return; -- Never sent presence there, can't be a MUC join
29 end 30 end
30 31
31 -- Check for status code 110, meaning it's their own reflected presence 32 -- Check for status code 110, meaning it's their own reflected presence
32 for status in muc_x:childtags("status") do 33 for status in muc_x:childtags("status") do