Diff

plugins/mod_component.lua @ 11868:ae093c259da2

mod_c2s,etc: Identify stanza object with appropriate function Better than duck typing, in case anyone ever passes a non-stanza table with a 'name' field.
author Kim Alvefur <zash@zash.se>
date Sun, 24 Oct 2021 15:17:01 +0200
parent 11560:3bbb1af92514
child 12686:5f182bccf33f
line wrap: on
line diff
--- a/plugins/mod_component.lua	Sun Oct 24 15:11:01 2021 +0200
+++ b/plugins/mod_component.lua	Sun Oct 24 15:17:01 2021 +0200
@@ -265,6 +265,9 @@
 			if type(reason) == "string" then -- assume stream error
 				module:log("info", "Disconnecting component, <stream:error> is: %s", reason);
 				session.send(st.stanza("stream:error"):tag(reason, {xmlns = 'urn:ietf:params:xml:ns:xmpp-streams' }));
+			elseif st.is_stanza(reason) then
+				module:log("info", "Disconnecting component, <stream:error> is: %s", reason);
+				session.send(reason);
 			elseif type(reason) == "table" then
 				if reason.condition then
 					local stanza = st.stanza("stream:error"):tag(reason.condition, stream_xmlns_attr):up();
@@ -276,9 +279,6 @@
 					end
 					module:log("info", "Disconnecting component, <stream:error> is: %s", stanza);
 					session.send(stanza);
-				elseif reason.name then -- a stanza
-					module:log("info", "Disconnecting component, <stream:error> is: %s", reason);
-					session.send(reason);
 				end
 			end
 		end