Software /
code /
prosody-modules
Changeset
1925:552faee596b7
mod_throttle_presence: Switch if-else statement around to improve readability
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 23 Oct 2015 16:48:11 +0200 |
parents | 1924:c84cf61ca0f3 |
children | 1926:4c4a4191b825 |
files | mod_throttle_presence/mod_throttle_presence.lua |
diffstat | 1 files changed, 5 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_throttle_presence/mod_throttle_presence.lua Fri Oct 23 15:51:41 2015 +0200 +++ b/mod_throttle_presence/mod_throttle_presence.lua Fri Oct 23 16:48:11 2015 +0200 @@ -13,7 +13,11 @@ end local buffer = session.presence_buffer; local from = stanza.attr.from; - if stanza.name ~= "presence" or (stanza.attr.type and stanza.attr.type ~= "unavailable") then + if stanza.name == "presence" and (stanza.attr.type == nil or stanza.attr.type == "unavailable") then + module:log("debug", "Buffering presence stanza from %s to %s", stanza.attr.from, session.full_jid); + buffer[stanza.attr.from] = st.clone(stanza); + return nil; -- Drop this stanza (we've stored it for later) + else local cached_presence = buffer[stanza.attr.from]; if cached_presence then module:log("debug", "Important stanza for %s from %s, flushing presence", session.full_jid, from); @@ -22,10 +26,6 @@ session.send(cached_presence); buffer[stanza.attr.from] = nil; end - else - module:log("debug", "Buffering presence stanza from %s to %s", stanza.attr.from, session.full_jid); - buffer[stanza.attr.from] = st.clone(stanza); - return nil; -- Drop this stanza (we've stored it for later) end return stanza; end