diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_c2s.lua | 4 | ||||
-rw-r--r-- | plugins/mod_carbons.lua | 10 | ||||
-rw-r--r-- | plugins/mod_mam/mod_mam.lua | 19 | ||||
-rw-r--r-- | plugins/mod_s2s.lua | 4 |
4 files changed, 27 insertions, 10 deletions
diff --git a/plugins/mod_c2s.lua b/plugins/mod_c2s.lua index 33fd7a0a..c8f54fa7 100644 --- a/plugins/mod_c2s.lua +++ b/plugins/mod_c2s.lua @@ -433,7 +433,7 @@ module:hook("server-stopping", function(event) -- luacheck: ignore 212/event end, -80); module:hook("server-stopping", function(event) - local wait, done = async.waiter(); + local wait, done = async.waiter(1, true); module:hook("c2s-closed", function () if next(sessions) == nil then done(); end end) @@ -446,7 +446,7 @@ module:hook("server-stopping", function(event) -- Wait for them to close properly if they haven't already if next(sessions) ~= nil then - add_task(stream_close_timeout+1, done); + add_task(stream_close_timeout+1, function () done() end); module:log("info", "Waiting for sessions to close"); wait(); end diff --git a/plugins/mod_carbons.lua b/plugins/mod_carbons.lua index 5b0bdeb7..7a5b757c 100644 --- a/plugins/mod_carbons.lua +++ b/plugins/mod_carbons.lua @@ -69,6 +69,12 @@ local function should_copy(stanza, c2s, user_bare) --> boolean, reason: string return false, "default"; end +module:hook("carbons-should-copy", function (event) + local should, why = should_copy(event.stanza); + event.reason = why; + return should; +end, -1) + local function message_handler(event, c2s) local origin, stanza = event.origin, event.stanza; local orig_type = stanza.attr.type or "normal"; @@ -101,7 +107,9 @@ local function message_handler(event, c2s) return -- No use in sending carbons to an offline user end - local should, why = should_copy(stanza, c2s, bare_jid); + local event_payload = { stanza = stanza; session = origin }; + local should = module:fire_event("carbons-should-copy", event_payload); + local why = event_payload.reason; if not should then module:log("debug", "Not copying stanza: %s (%s)", stanza:top_tag(), why); diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua index d4b2b060..50095e2f 100644 --- a/plugins/mod_mam/mod_mam.lua +++ b/plugins/mod_mam/mod_mam.lua @@ -54,7 +54,7 @@ end local use_total = module:get_option_boolean("mam_include_total", true); function schedule_cleanup() - -- replaced by non-noop later if cleanup is enabled + -- replaced later if cleanup is enabled end -- Handle prefs. @@ -311,7 +311,7 @@ local function strip_stanza_id(stanza, user) return stanza; end -local function should_store(stanza, c2s) --> boolean, reason: string +local function should_store(stanza) --> boolean, reason: string local st_type = stanza.attr.type or "normal"; -- FIXME pass direction of stanza and use that along with bare/full JID addressing -- for more accurate MUC / type=groupchat check @@ -320,7 +320,7 @@ local function should_store(stanza, c2s) --> boolean, reason: string -- Headline messages are ephemeral by definition return false, "headline"; end - if st_type == "error" and not c2s then + if st_type == "error" then -- Errors not sent sent from a local client -- Why would a client send an error anyway? if jid_resource(stanza.attr.to) then @@ -380,6 +380,12 @@ local function should_store(stanza, c2s) --> boolean, reason: string return false, "default"; end +module:hook("archive-should-store", function (event) + local should, why = should_store(event.stanza); + event.reason = why; + return should; +end, -1) + -- Handle messages local function message_handler(event, c2s) local origin, stanza = event.origin, event.stanza; @@ -396,9 +402,12 @@ local function message_handler(event, c2s) -- Filter out <stanza-id> that claim to be from us event.stanza = strip_stanza_id(stanza, store_user); - local should, why = should_store(stanza, c2s); + local event_payload = { stanza = stanza; session = origin }; + local should = module:fire_event("archive-should-store", event_payload); + local why = event_payload.reason; + if not should then - log("debug", "Not archiving stanza: %s (%s)", stanza:top_tag(), why); + log("debug", "Not archiving stanza: %s (%s)", stanza:top_tag(), event_payload.reason); return; end diff --git a/plugins/mod_s2s.lua b/plugins/mod_s2s.lua index 655cb599..3ad0f521 100644 --- a/plugins/mod_s2s.lua +++ b/plugins/mod_s2s.lua @@ -973,7 +973,7 @@ module:hook("server-stopping", function(event) end end - local wait, done = async.waiter(); + local wait, done = async.waiter(1, true); module:hook("s2s-closed", function () if next(sessions) == nil then done(); end end, 1) @@ -987,7 +987,7 @@ module:hook("server-stopping", function(event) -- Wait for them to close properly if they haven't already if next(sessions) ~= nil then module:log("info", "Waiting for sessions to close"); - add_task(stream_close_timeout + 1, done); + add_task(stream_close_timeout + 1, function () done() end); wait(); end |