mirror of
https://github.com/bjc/prosody.git
synced 2025-04-01 20:27:39 +03:00
mod_carbons: Allow plugging into decision of whether to carbon-copy
Similar procedure as mod_csi_simple and mod_mam
This commit is contained in:
parent
58b97fd7af
commit
e725335ed3
1 changed files with 9 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue