Changeset

11996:3dd7886f9342

mod_smacks: Use function to construct error reply Did error_reply() not exist when mod_smacks was first created?
author Kim Alvefur <zash@zash.se>
date Fri, 03 Dec 2021 00:59:23 +0100
parents 11995:bbd3ac65640d
children 11997:1ea01660c79a
files plugins/mod_smacks.lua
diffstat 1 files changed, 1 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_smacks.lua	Fri Dec 03 00:11:31 2021 +0100
+++ b/plugins/mod_smacks.lua	Fri Dec 03 00:59:23 2021 +0100
@@ -395,17 +395,13 @@
 
 local function handle_unacked_stanzas(session)
 	local queue = session.outgoing_stanza_queue;
-	local error_attr = { type = "cancel" };
 	if #queue > 0 then
 		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
-					local reply = st.reply(queue[i]);
+					local reply = st.error_reply(queue[i], "cancel", "recipient-unavailable");
 					if reply.attr.to ~= session.full_jid then
-						reply.attr.type = "error";
-						reply:tag("error", error_attr)
-							:tag("recipient-unavailable", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"});
 						core_process_stanza(session, reply);
 					end
 				end