Changeset

10639:08e3063eb1ac

stanza_router: Add once-per-routed-stanza event, pre-stanza
author Matthew Wild <mwild1@gmail.com>
date Wed, 05 Feb 2020 17:40:50 +0000
parents 10638:92918212ee83
children 10640:5622eda7c5c5
files core/stanza_router.lua
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/core/stanza_router.lua	Sat Feb 01 00:33:08 2020 +0100
+++ b/core/stanza_router.lua	Wed Feb 05 17:40:50 2020 +0000
@@ -172,7 +172,14 @@
 		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