Software /
code /
prosody-modules
Comparison
mod_throttle_presence/mod_throttle_presence.lua @ 1488:ba97f9be4f76
mod_throttle_presence: Fix traceback (thanks Ge0rG)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 17 Aug 2014 20:21:09 +0200 |
parent | 1485:d8c50448d0e7 |
child | 1489:95f10fb7f60e |
comparison
equal
deleted
inserted
replaced
1487:5410f5c30d63 | 1488:ba97f9be4f76 |
---|---|
20 end | 20 end |
21 return stanza; | 21 return stanza; |
22 end | 22 end |
23 | 23 |
24 local function throttle_session(event) | 24 local function throttle_session(event) |
25 local session = event.session; | 25 local session = event.origin; |
26 if session.presence_buffer then return; end | 26 if session.presence_buffer then return; end |
27 module:log("debug", "Suppressing presence updates to %s", session.full_jid); | 27 module:log("debug", "Suppressing presence updates to %s", session.full_jid); |
28 session.presence_buffer = {}; | 28 session.presence_buffer = {}; |
29 filters.add_filter(session, "stanzas/out", presence_filter); | 29 filters.add_filter(session, "stanzas/out", presence_filter); |
30 end | 30 end |
31 | 31 |
32 local function restore_session(event) | 32 local function restore_session(event) |
33 local session = event.session; | 33 local session = event.origin; |
34 if not session.presence_buffer then return; end | 34 if not session.presence_buffer then return; end |
35 filters.remove_filter(session, "stanzas/out", presence_filter); | 35 filters.remove_filter(session, "stanzas/out", presence_filter); |
36 module:log("debug", "Flushing buffer for %s", session.full_jid); | 36 module:log("debug", "Flushing buffer for %s", session.full_jid); |
37 for jid, presence in pairs(session.presence_buffer) do | 37 for jid, presence in pairs(session.presence_buffer) do |
38 session.send(presence); | 38 session.send(presence); |