stanza_router: Fire global event if host doesn't have events, fixes #103

Sun, 31 May 2009 21:35:21 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Sun, 31 May 2009 21:35:21 +0100
changeset 1256
98f0e9eadf3b
parent 1255
a25b12c105bb
child 1257
8c9f20d3a17f
child 1262
0d94c57555d9

stanza_router: Fire global event if host doesn't have events, fixes #103

core/stanza_router.lua file | annotate | diff | comparison | revisions
--- a/core/stanza_router.lua	Sun May 31 21:31:02 2009 +0100
+++ b/core/stanza_router.lua	Sun May 31 21:35:21 2009 +0100
@@ -127,7 +127,7 @@
 			else
 				event = "stanza/"..stanza.attr.xmlns..":"..stanza.name;
 			end
-			if h.events.fire_event(event, {origin = origin, stanza = stanza}) then return; end
+			if (h.events or prosody.events).fire_event(event, {origin = origin, stanza = stanza}) then return; end
 		end
 		modules_handle_stanza(host or origin.host or origin.to_host, origin, stanza);
 	end
@@ -155,7 +155,7 @@
 
 	local event_data = {origin=origin, stanza=stanza};
 	if origin.full_jid then -- c2s connection
-		if hosts[origin.host].events.fire_event('pre-'..stanza.name..to_type, event_data) then return; end -- do preprocessing
+		if (hosts[origin.host].events or prosody.events).fire_event('pre-'..stanza.name..to_type, event_data) then return; end -- do preprocessing
 	end
 	local h = hosts[to_bare] or hosts[host or origin.host];
 	if h then
@@ -163,7 +163,7 @@
 			component_handle_stanza(origin, stanza);
 			return;
 		else
-			if h.events.fire_event(stanza.name..to_type, event_data) then return; end -- do processing
+			if (h.events or prosody.events).fire_event(stanza.name..to_type, event_data) then return; end -- do processing
 		end
 	else -- non-local recipient
 		core_route_stanza(origin, stanza);

mercurial