Software /
code /
prosody
Comparison
plugins/mod_c2s.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 | 11778:f254fd16218a |
child | 11899:6d06068363aa |
comparison
equal
deleted
inserted
replaced
11867:bb20cfd4884f | 11868:ae093c259da2 |
---|---|
192 end | 192 end |
193 if reason then -- nil == no err, initiated by us, false == initiated by client | 193 if reason then -- nil == no err, initiated by us, false == initiated by client |
194 local stream_error = st.stanza("stream:error"); | 194 local stream_error = st.stanza("stream:error"); |
195 if type(reason) == "string" then -- assume stream error | 195 if type(reason) == "string" then -- assume stream error |
196 stream_error:tag(reason, {xmlns = 'urn:ietf:params:xml:ns:xmpp-streams' }); | 196 stream_error:tag(reason, {xmlns = 'urn:ietf:params:xml:ns:xmpp-streams' }); |
197 elseif st.is_stanza(reason) then | |
198 stream_error = reason; | |
197 elseif type(reason) == "table" then | 199 elseif type(reason) == "table" then |
198 if reason.condition then | 200 if reason.condition then |
199 stream_error:tag(reason.condition, stream_xmlns_attr):up(); | 201 stream_error:tag(reason.condition, stream_xmlns_attr):up(); |
200 if reason.text then | 202 if reason.text then |
201 stream_error:tag("text", stream_xmlns_attr):text(reason.text):up(); | 203 stream_error:tag("text", stream_xmlns_attr):text(reason.text):up(); |
202 end | 204 end |
203 if reason.extra then | 205 if reason.extra then |
204 stream_error:add_child(reason.extra); | 206 stream_error:add_child(reason.extra); |
205 end | 207 end |
206 elseif reason.name then -- a stanza | |
207 stream_error = reason; | |
208 end | 208 end |
209 end | 209 end |
210 stream_error = tostring(stream_error); | 210 stream_error = tostring(stream_error); |
211 log("debug", "Disconnecting client, <stream:error> is: %s", stream_error); | 211 log("debug", "Disconnecting client, <stream:error> is: %s", stream_error); |
212 session.send(stream_error); | 212 session.send(stream_error); |