Software /
code /
prosody
Changeset
12308:063ce658c181
mod_carbons: Allow plugging into decision of whether to carbon-copy
Similar procedure as mod_csi_simple and mod_mam
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 21 Feb 2022 11:24:58 +0100 |
parents | 12307:dcad3a207915 |
children | 12309:926a6c5d13e7 |
files | plugins/mod_carbons.lua |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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);