mod_smacks: Refactor, simplify, optimize
authorKim Alvefur <zash@zash.se>
Fri, 03 Dec 2021 01:02:02 +0100
changeset 12001 1ea01660c79a
parent 12000 3dd7886f9342
child 12002 99be6874340b
mod_smacks: Refactor, simplify, optimize Since reply.attr.to will be the .attr.from of the input we can check this earlier and avoid constructing the reply at all.
plugins/mod_smacks.lua
--- a/plugins/mod_smacks.lua	Fri Dec 03 00:59:23 2021 +0100
+++ b/plugins/mod_smacks.lua	Fri Dec 03 01:02:02 2021 +0100
@@ -399,11 +399,9 @@
 		session.outgoing_stanza_queue = {};
 		for i=1,#queue do
 			if not module:fire_event("delivery/failure", { session = session, stanza = queue[i] }) then
-				if queue[i].attr.type ~= "error" then
+				if queue[i].attr.type ~= "error" and queue[i].attr.from ~= session.full_jid then
 					local reply = st.error_reply(queue[i], "cancel", "recipient-unavailable");
-					if reply.attr.to ~= session.full_jid then
-						core_process_stanza(session, reply);
-					end
+					core_process_stanza(session, reply);
 				end
 			end
 		end