# HG changeset patch # User Kim Alvefur # Date 1645439098 -3600 # Node ID 063ce658c18177c8783096b64038f2c4fc3d9004 # Parent dcad3a207915730259968b55b4ecb979c9b92bbc mod_carbons: Allow plugging into decision of whether to carbon-copy Similar procedure as mod_csi_simple and mod_mam diff -r dcad3a207915 -r 063ce658c181 plugins/mod_carbons.lua --- a/plugins/mod_carbons.lua Sat Dec 11 18:01:04 2021 +0100 +++ b/plugins/mod_carbons.lua Mon Feb 21 11:24:58 2022 +0100 @@ -69,6 +69,12 @@ 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 @@ 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);