diff options
author | Kim Alvefur <zash@zash.se> | 2022-02-21 11:24:58 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2022-02-21 11:24:58 +0100 |
commit | e725335ed389622ebad4b84997e9bd22bd2e6a7b (patch) | |
tree | 80d208ed0ad6d6e8496dc80bbea8f4a00c8d2020 /plugins | |
parent | 58b97fd7af3b482f9c98ff6a74552fb67cc29ef1 (diff) | |
download | prosody-e725335ed389622ebad4b84997e9bd22bd2e6a7b.tar.gz prosody-e725335ed389622ebad4b84997e9bd22bd2e6a7b.zip |
mod_carbons: Allow plugging into decision of whether to carbon-copy
Similar procedure as mod_csi_simple and mod_mam
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_carbons.lua | 10 |
1 files changed, 9 insertions, 1 deletions
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); |