changeset 1504:b8164f18142a

mod_throttle_presence: Make sure flushed stanzas get through the filter
author Kim Alvefur <zash@zash.se>
date Tue, 16 Sep 2014 16:44:32 +0200
parents c4c9ccc6e6c9
children ba71d0ad5564
files mod_throttle_presence/mod_throttle_presence.lua
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_throttle_presence/mod_throttle_presence.lua	Tue Sep 16 16:23:15 2014 +0200
+++ b/mod_throttle_presence/mod_throttle_presence.lua	Tue Sep 16 16:44:32 2014 +0200
@@ -4,12 +4,18 @@
 module:depends("csi");
 
 local function presence_filter(stanza, session)
+	if stanza._flush then
+		stanza._flush = nil;
+		return stanza;
+	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
 		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);
+			stanza._flush = true;
+			cached_presence._flush = true;
 			session.send(cached_presence);
 			buffer[stanza.attr.from] = nil;
 		end