stanza_router: Fire events after all checks

Fri, 15 May 2009 23:42:35 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Fri, 15 May 2009 23:42:35 +0500
changeset 1163
8b4a57765b04
parent 1157
279f79389189
child 1164
251954b07cae

stanza_router: Fire events after all checks

core/stanza_router.lua file | annotate | diff | comparison | revisions
--- a/core/stanza_router.lua	Fri May 15 08:42:53 2009 +0500
+++ b/core/stanza_router.lua	Fri May 15 23:42:35 2009 +0500
@@ -107,8 +107,6 @@
 	end]] -- FIXME
 
 	if (origin.type == "s2sin" or origin.type == "c2s" or origin.type == "component") and (not xmlns or xmlns == "jabber:server" or xmlns == "jabber:client") then			
-		local event_data = {origin=origin, stanza=stanza};
-		if fire_event(tostring(host or origin.host).."/"..stanza.name, event_data) then return; end
 		if origin.type == "s2sin" and not origin.dummy then
 			local host_status = origin.hosts[from_host];
 			if not host_status or not host_status.authed then -- remote server trying to impersonate some other server?
@@ -116,7 +114,10 @@
 				return; -- FIXME what should we do here? does this work with subdomains?
 			end
 		end
-		if not to then
+		local event_data = {origin=origin, stanza=stanza};
+		if fire_event(tostring(host or origin.host).."/"..stanza.name, event_data) then
+			-- event handled
+		elseif not to then
 			core_handle_stanza(origin, stanza);
 		elseif hosts[to] and hosts[to].type == "local" then -- directed at a local server
 			core_handle_stanza(origin, stanza);

mercurial