Software /
code /
prosody-modules
Comparison
mod_track_muc_joins/mod_track_muc_joins.lua @ 2157:7d1a22ac2a21
mod_track_muc_joins: Only check directed presence when joining (would be gone when leaving)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 13 Apr 2016 11:52:51 +0200 |
parent | 2156:3fcac143fe0b |
child | 2158:de3fb9d2673c |
comparison
equal
deleted
inserted
replaced
2156:3fcac143fe0b | 2157:7d1a22ac2a21 |
---|---|
5 local stanza = event.stanza; | 5 local stanza = event.stanza; |
6 local session = sessions[stanza.attr.to]; | 6 local session = sessions[stanza.attr.to]; |
7 if not session then return end; | 7 if not session then return end; |
8 local log = session.log or module._log; | 8 local log = session.log or module._log; |
9 | 9 |
10 local from_jid = stanza.attr.from; | |
11 if not session.directed or not session.directed[from_jid] then | |
12 return; -- Never sent presence there, can't be a MUC join | |
13 end | |
14 | |
15 local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc#user"); | 10 local muc_x = stanza:get_child("x", "http://jabber.org/protocol/muc#user"); |
16 if not muc_x then return end -- Not MUC related | 11 if not muc_x then return end -- Not MUC related |
17 | 12 |
13 local from_jid = stanza.attr.from; | |
18 local room = jid_bare(from_jid); | 14 local room = jid_bare(from_jid); |
19 local joined = stanza.attr.type; | 15 local joined = stanza.attr.type; |
20 if joined == nil then | 16 if joined == nil then |
21 joined = true; | 17 joined = true; |
22 elseif joined == "unavailable" then | 18 elseif joined == "unavailable" then |
23 joined = nil; | 19 joined = nil; |
24 else | 20 else |
25 -- Ignore errors and whatever | 21 -- Ignore errors and whatever |
26 return; | 22 return; |
23 end | |
24 | |
25 if joined and not session.directed or not session.directed[from_jid] then | |
26 return; -- Never sent presence there, can't be a MUC join | |
27 end | 27 end |
28 | 28 |
29 -- Check for status code 100, meaning it's their own reflected presence | 29 -- Check for status code 100, meaning it's their own reflected presence |
30 for status in muc_x:childtags("status") do | 30 for status in muc_x:childtags("status") do |
31 log("debug", "Status code %d", status.attr.code); | 31 log("debug", "Status code %d", status.attr.code); |