diff mod_smacks/mod_smacks.lua @ 1517:8ac4438925cf

mod_smacks: Examine the state of the stanza *before* it was send
author Florian Zeitz <florob@babelmonkeys.de>
date Tue, 30 Sep 2014 01:17:10 +0200
parents feca77ad88ac
children 9475fe14d58d
line wrap: on
line diff
--- a/mod_smacks/mod_smacks.lua	Sat Sep 27 19:29:28 2014 +0200
+++ b/mod_smacks/mod_smacks.lua	Tue Sep 30 01:17:10 2014 +0200
@@ -82,8 +82,8 @@
 
 	local _send = session.sends2s or session.send;
 	local function new_send(stanza)
-		local attr = stanza.attr;
-		if attr and not attr.xmlns then -- Stanza in default stream namespace
+		local xmlns = stanza.attr and stanza.attr.xmlns;
+		if not xmlns then -- Stanza in default stream namespace
 			local cached_stanza = st.clone(stanza);
 
 			if cached_stanza and cached_stanza:get_child("delay", xmlns_delay) == nil then
@@ -100,7 +100,7 @@
 			return true;
 		end
 		local ok, err = _send(stanza);
-		if ok and #queue > max_unacked_stanzas and not session.awaiting_ack and attr and not attr.xmlns then
+		if ok and #queue > max_unacked_stanzas and not session.awaiting_ack and not xmlns then
 			session.awaiting_ack = true;
 			return _send(st.stanza("r", sm_attr));
 		end