Diff

plugins/mod_s2s/mod_s2s.lua @ 8463:d81ebb1ef5ce

mod_s2s: Restructure some code
author Kim Alvefur <zash@zash.se>
date Tue, 05 Dec 2017 13:24:28 +0100
parent 8462:60d508f411a1
child 8483:6d47b74926dd
line wrap: on
line diff
--- a/plugins/mod_s2s/mod_s2s.lua	Tue Dec 05 12:35:01 2017 +0100
+++ b/plugins/mod_s2s/mod_s2s.lua	Tue Dec 05 13:24:28 2017 +0100
@@ -106,8 +106,15 @@
 			(host.log or log)("debug", "trying to send over unauthed s2sout to "..to_host);
 
 			-- Queue stanza until we are able to send it
-			if host.sendq then t_insert(host.sendq, {tostring(stanza), stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza)});
-			else host.sendq = { {tostring(stanza), stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza)} }; end
+			local queued_item = {
+				tostring(stanza),
+				stanza.attr.type ~= "error" and stanza.attr.type ~= "result" and st.reply(stanza);
+			};
+			if host.sendq then
+				t_insert(host.sendq, queued_item);
+			else
+				host.sendq = { queued_item };
+			end
 			host.log("debug", "stanza [%s] queued ", stanza.name);
 			return true;
 		elseif host.type == "local" or host.type == "component" then