From ef6cb64b9edf578685bedc02f72ed27bbc1d974f Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 24 Oct 2021 15:17:01 +0200 Subject: 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. --- plugins/mod_websocket.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/mod_websocket.lua') diff --git a/plugins/mod_websocket.lua b/plugins/mod_websocket.lua index 04a8303a..f0134b4a 100644 --- a/plugins/mod_websocket.lua +++ b/plugins/mod_websocket.lua @@ -71,6 +71,8 @@ local function session_close(session, reason) local stream_error = st.stanza("stream:error"); if type(reason) == "string" then -- assume stream error stream_error:tag(reason, {xmlns = 'urn:ietf:params:xml:ns:xmpp-streams' }); + elseif st.is_stanza(reason) then + stream_error = reason; elseif type(reason) == "table" then if reason.condition then stream_error:tag(reason.condition, stream_xmlns_attr):up(); @@ -80,8 +82,6 @@ local function session_close(session, reason) if reason.extra then stream_error:add_child(reason.extra); end - elseif reason.name then -- a stanza - stream_error = reason; end end log("debug", "Disconnecting client, is: %s", stream_error); -- cgit v1.2.3