Software /
code /
prosody
Comparison
plugins/mod_csi_simple.lua @ 9649:a20849226598 0.11
mod_csi_simple: Bypass importance event in active mode (fixes #1249)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 27 Nov 2018 19:05:11 +0100 |
parent | 9648:dfebf6cac027 |
child | 9650:db6bcafd76c9 |
comparison
equal
deleted
inserted
replaced
9648:dfebf6cac027 | 9649:a20849226598 |
---|---|
69 return true; | 69 return true; |
70 end, -1); | 70 end, -1); |
71 | 71 |
72 module:hook("csi-client-inactive", function (event) | 72 module:hook("csi-client-inactive", function (event) |
73 local session = event.origin; | 73 local session = event.origin; |
74 session.state = "inactive"; | |
74 if session.pump then | 75 if session.pump then |
75 session.pump:pause(); | 76 session.pump:pause(); |
76 else | 77 else |
77 local bare_jid = jid.join(session.username, session.host); | 78 local bare_jid = jid.join(session.username, session.host); |
78 local send = session.send; | 79 local send = session.send; |
79 session._orig_send = send; | 80 session._orig_send = send; |
80 local pump = new_pump(session.send, queue_size); | 81 local pump = new_pump(session.send, queue_size); |
81 pump:pause(); | 82 pump:pause(); |
82 session.pump = pump; | 83 session.pump = pump; |
83 function session.send(stanza) | 84 function session.send(stanza) |
84 if module:fire_event("csi-is-stanza-important", { stanza = stanza, session = session }) then | 85 if session.state == "active" or module:fire_event("csi-is-stanza-important", { stanza = stanza, session = session }) then |
85 pump:flush(); | 86 pump:flush(); |
86 send(stanza); | 87 send(stanza); |
87 else | 88 else |
88 if st.is_stanza(stanza) and st.attr.xmlns == nil and st.name ~= "iq" then | 89 if st.is_stanza(stanza) and st.attr.xmlns == nil and st.name ~= "iq" then |
89 stanza = st.clone(stanza); | 90 stanza = st.clone(stanza); |
96 end | 97 end |
97 end); | 98 end); |
98 | 99 |
99 module:hook("csi-client-active", function (event) | 100 module:hook("csi-client-active", function (event) |
100 local session = event.origin; | 101 local session = event.origin; |
102 session.state = "active"; | |
101 if session.pump then | 103 if session.pump then |
102 session.pump:resume(); | 104 session.pump:resume(); |
103 end | 105 end |
104 end); | 106 end); |
105 | 107 |