aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2020-02-05 17:40:50 +0000
committerMatthew Wild <mwild1@gmail.com>2020-02-05 17:40:50 +0000
commitfd3ee50a8c1aa3029d8edecf584bea8acda9edc7 (patch)
tree3c1a147a8f14c323983da458f16cc2778bc41f56
parent0f96c438e5b03eea8d1a1126333b99a3018c0bfb (diff)
downloadprosody-fd3ee50a8c1aa3029d8edecf584bea8acda9edc7.tar.gz
prosody-fd3ee50a8c1aa3029d8edecf584bea8acda9edc7.zip
stanza_router: Add once-per-routed-stanza event, pre-stanza
-rw-r--r--core/stanza_router.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/core/stanza_router.lua b/core/stanza_router.lua
index 1d8db3e7..b2712b2f 100644
--- a/core/stanza_router.lua
+++ b/core/stanza_router.lua
@@ -172,7 +172,14 @@ function core_post_stanza(origin, stanza, preevents)
end
end
- local event_data = {origin=origin, stanza=stanza};
+ local event_data = {origin=origin, stanza=stanza, to_self=to_self};
+
+ local result = hosts[origin.host].events.fire_event("pre-stanza", event_data);
+ if result ~= nil then
+ log("debug", "Stanza rejected by pre-stanza handler: %s", event_data.reason or "unknown reason");
+ return;
+ end
+
if preevents then -- c2s connection
if hosts[origin.host].events.fire_event('pre-'..stanza.name..to_type, event_data) then return; end -- do preprocessing
end