diff mod_smacks/mod_smacks.lua @ 1518:9475fe14d58d

mod_smacks: Correctly check if what is being sent is a stanza
author Kim Alvefur <zash@zash.se>
date Wed, 08 Oct 2014 12:56:21 +0200
parents 8ac4438925cf
children 2881d532f385
line wrap: on
line diff
--- a/mod_smacks/mod_smacks.lua	Tue Sep 30 01:17:10 2014 +0200
+++ b/mod_smacks/mod_smacks.lua	Wed Oct 08 12:56:21 2014 +0200
@@ -82,8 +82,9 @@
 
 	local _send = session.sends2s or session.send;
 	local function new_send(stanza)
-		local xmlns = stanza.attr and stanza.attr.xmlns;
-		if not xmlns then -- Stanza in default stream namespace
+		local is_stanza = stanza.attr and not stanza.attr.xmlns;
+		if is_stanza then -- Stanza in default stream namespace
+			module:log("debug", "st.clone( %s ) -- %s a stanza", tostring(stanza), is_stanza and "is" or "is not");
 			local cached_stanza = st.clone(stanza);
 
 			if cached_stanza and cached_stanza:get_child("delay", xmlns_delay) == nil then
@@ -100,7 +101,7 @@
 			return true;
 		end
 		local ok, err = _send(stanza);
-		if ok and #queue > max_unacked_stanzas and not session.awaiting_ack and not xmlns then
+		if ok and #queue > max_unacked_stanzas and not session.awaiting_ack and is_stanza then
 			session.awaiting_ack = true;
 			return _send(st.stanza("r", sm_attr));
 		end