Software /
code /
prosody
Diff
plugins/mod_websocket.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 | 11771:4c0802b52673 |
child | 12263:168970ce8543 |
line wrap: on
line diff
--- a/plugins/mod_websocket.lua Sun Oct 24 15:11:01 2021 +0200 +++ b/plugins/mod_websocket.lua Sun Oct 24 15:17:01 2021 +0200 @@ -71,6 +71,8 @@ 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 @@ 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, <stream:error> is: %s", stream_error);