stanza_router: Fire events for non-jabber:client and pre-auth stanzas

Sun, 31 May 2009 02:20:30 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Sun, 31 May 2009 02:20:30 +0500
changeset 1254
c199be608546
parent 1253
60156584c442
child 1255
a25b12c105bb
child 1259
6bd11bca9725

stanza_router: Fire events for non-jabber:client and pre-auth stanzas

core/stanza_router.lua file | annotate | diff | comparison | revisions
--- a/core/stanza_router.lua	Sun May 31 01:17:19 2009 +0500
+++ b/core/stanza_router.lua	Sun May 31 02:20:30 2009 +0500
@@ -115,6 +115,20 @@
 		end
 		core_post_stanza(origin, stanza);
 	else
+		local h = hosts[stanza.attr.to or origin.host or origin.to_host];
+		if h then
+			local event;
+			if stanza.attr.xmlns == "jabber:client" then
+				if stanza.name == "iq" and (stanza.attr.type == "set" or stanza.attr.type == "get") then
+					event = "stanza/iq/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name;
+				else
+					event = "stanza/"..stanza.name;
+				end
+			else
+				event = "stanza/"..stanza.attr.xmlns..":"..stanza.name;
+			end
+			if h.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
 end

mercurial