# HG changeset patch # User Kim Alvefur # Date 1445611691 -7200 # Node ID 552faee596b7e45b549799ed5dd562b0be38249f # Parent c84cf61ca0f3b86685365b84258cd229e4e75319 mod_throttle_presence: Switch if-else statement around to improve readability diff -r c84cf61ca0f3 -r 552faee596b7 mod_throttle_presence/mod_throttle_presence.lua --- 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