diff mod_throttle_presence/mod_throttle_presence.lua @ 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 95f10fb7f60e
children 34468d3bfcac
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