Software / code / prosody
Comparison
plugins/mod_smacks.lua @ 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 |
| parent | 11985:3740cf7a66a3 |
| child | 11997:1ea01660c79a |
comparison
equal
deleted
inserted
replaced
| 11995:bbd3ac65640d | 11996:3dd7886f9342 |
|---|---|
| 393 module:hook_tag(xmlns_sm2, "a", handle_a); | 393 module:hook_tag(xmlns_sm2, "a", handle_a); |
| 394 module:hook_tag(xmlns_sm3, "a", handle_a); | 394 module:hook_tag(xmlns_sm3, "a", handle_a); |
| 395 | 395 |
| 396 local function handle_unacked_stanzas(session) | 396 local function handle_unacked_stanzas(session) |
| 397 local queue = session.outgoing_stanza_queue; | 397 local queue = session.outgoing_stanza_queue; |
| 398 local error_attr = { type = "cancel" }; | |
| 399 if #queue > 0 then | 398 if #queue > 0 then |
| 400 session.outgoing_stanza_queue = {}; | 399 session.outgoing_stanza_queue = {}; |
| 401 for i=1,#queue do | 400 for i=1,#queue do |
| 402 if not module:fire_event("delivery/failure", { session = session, stanza = queue[i] }) then | 401 if not module:fire_event("delivery/failure", { session = session, stanza = queue[i] }) then |
| 403 if queue[i].attr.type ~= "error" then | 402 if queue[i].attr.type ~= "error" then |
| 404 local reply = st.reply(queue[i]); | 403 local reply = st.error_reply(queue[i], "cancel", "recipient-unavailable"); |
| 405 if reply.attr.to ~= session.full_jid then | 404 if reply.attr.to ~= session.full_jid then |
| 406 reply.attr.type = "error"; | |
| 407 reply:tag("error", error_attr) | |
| 408 :tag("recipient-unavailable", {xmlns = "urn:ietf:params:xml:ns:xmpp-stanzas"}); | |
| 409 core_process_stanza(session, reply); | 405 core_process_stanza(session, reply); |
| 410 end | 406 end |
| 411 end | 407 end |
| 412 end | 408 end |
| 413 end | 409 end |