43 local max_unacked_stanzas = module:get_option_number("smacks_max_unacked_stanzas", 0); |
43 local max_unacked_stanzas = module:get_option_number("smacks_max_unacked_stanzas", 0); |
44 local max_inactive_unacked_stanzas = module:get_option_number("smacks_max_inactive_unacked_stanzas", 256); |
44 local max_inactive_unacked_stanzas = module:get_option_number("smacks_max_inactive_unacked_stanzas", 256); |
45 local delayed_ack_timeout = module:get_option_number("smacks_max_ack_delay", 30); |
45 local delayed_ack_timeout = module:get_option_number("smacks_max_ack_delay", 30); |
46 |
46 |
47 local c2s_sessions = module:shared("/*/c2s/sessions"); |
47 local c2s_sessions = module:shared("/*/c2s/sessions"); |
|
48 local local_sessions = prosody.hosts[module.host].sessions; |
48 |
49 |
49 local function format_h(h) if h then return string.format("%d", h) end end |
50 local function format_h(h) if h then return string.format("%d", h) end end |
50 |
51 |
51 local old_session_registry = module:open_store("smacks_h", "map"); |
52 local old_session_registry = module:open_store("smacks_h", "map"); |
52 local session_registry = module:shared "/*/smacks/resumption-tokens"; -- > user@host/resumption-token --> resource |
53 local session_registry = module:shared "/*/smacks/resumption-tokens"; -- > user@host/resumption-token --> resource |
411 if session.mam_requested and stanza_id ~= nil then |
412 if session.mam_requested and stanza_id ~= nil then |
412 session.log("debug", "mod_smacks delivery/failure returning true for mam-handled stanza: mam-archive-id=%s", tostring(stanza_id)); |
413 session.log("debug", "mod_smacks delivery/failure returning true for mam-handled stanza: mam-archive-id=%s", tostring(stanza_id)); |
413 return true; -- stanza handled, don't send an error |
414 return true; -- stanza handled, don't send an error |
414 end |
415 end |
415 -- store message in offline store, if this client does not use mam *and* was the last client online |
416 -- store message in offline store, if this client does not use mam *and* was the last client online |
416 local sessions = prosody.hosts[module.host].sessions[session.username] and |
417 local sessions = local_sessions[session.username] and local_sessions[session.username].sessions or nil; |
417 prosody.hosts[module.host].sessions[session.username].sessions or nil; |
|
418 if sessions and next(sessions) == session.resource and next(sessions, session.resource) == nil then |
418 if sessions and next(sessions) == session.resource and next(sessions, session.resource) == nil then |
419 local ok = module:fire_event("message/offline/handle", { origin = session, username = session.username, stanza = stanza }); |
419 local ok = module:fire_event("message/offline/handle", { origin = session, username = session.username, stanza = stanza }); |
420 session.log("debug", "mod_smacks delivery/failure returning %s for offline-handled stanza", tostring(ok)); |
420 session.log("debug", "mod_smacks delivery/failure returning %s for offline-handled stanza", tostring(ok)); |
421 return ok; -- if stanza was handled, don't send an error |
421 return ok; -- if stanza was handled, don't send an error |
422 end |
422 end |