418 |
418 |
419 local function handle_unacked_stanzas(session) |
419 local function handle_unacked_stanzas(session) |
420 local queue = session.outgoing_stanza_queue; |
420 local queue = session.outgoing_stanza_queue; |
421 local unacked = queue:count_unacked() |
421 local unacked = queue:count_unacked() |
422 if unacked > 0 then |
422 if unacked > 0 then |
|
423 local error_from = jid.join(session.username, session.host or module.host); |
423 tx_dropped_stanzas:sample(unacked); |
424 tx_dropped_stanzas:sample(unacked); |
424 session.smacks = false; -- Disable queueing |
425 session.smacks = false; -- Disable queueing |
425 session.outgoing_stanza_queue = nil; |
426 session.outgoing_stanza_queue = nil; |
426 for stanza in queue._queue:consume() do |
427 for stanza in queue._queue:consume() do |
427 if not module:fire_event("delivery/failure", { session = session, stanza = stanza }) then |
428 if not module:fire_event("delivery/failure", { session = session, stanza = stanza }) then |
428 if stanza.attr.type ~= "error" and stanza.attr.from ~= session.full_jid then |
429 if stanza.attr.type ~= "error" and stanza.attr.from ~= session.full_jid then |
429 local reply = st.error_reply(stanza, "cancel", "recipient-unavailable"); |
430 local reply = st.error_reply(stanza, "cancel", "recipient-unavailable", nil, error_from); |
430 module:send(reply); |
431 module:send(reply); |
431 end |
432 end |
432 end |
433 end |
433 end |
434 end |
434 end |
435 end |