mod_iq: Fire sub-events for IQs directed at bare JIDs and hosts

Mon, 01 Jun 2009 05:35:32 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Mon, 01 Jun 2009 05:35:32 +0500
changeset 1260
04c1fae0eb03
parent 1259
6bd11bca9725
child 1261
497178e0ddbe

mod_iq: Fire sub-events for IQs directed at bare JIDs and hosts

plugins/mod_iq.lua file | annotate | diff | comparison | revisions
--- a/plugins/mod_iq.lua	Sun May 31 13:31:20 2009 +0500
+++ b/plugins/mod_iq.lua	Mon Jun 01 05:35:32 2009 +0500
@@ -22,12 +22,20 @@
 
 	-- TODO if not user exists, return an error
 	-- TODO fire post processing events
-	-- TODO fire event with the xmlns:tag of the child, or with the id of errors and results
+	if #stanza.tags == 1 then
+		return module:fire_event("iq/bare/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name);
+	else
+		return true; -- TODO do something with results and errors
+	end
 end);
 
 module:hook("iq/host", function(data)
 	-- IQ to a local host recieved
 	local origin, stanza = data.origin, data.stanza;
 
-	-- TODO fire event with the xmlns:tag of the child, or with the id of errors and results
+	if #stanza.tags == 1 then
+		return module:fire_event("iq/host/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name);
+	else
+		return true; -- TODO do something with results and errors
+	end
 end);

mercurial