mod_iq: Fire sub-events for iq/self events.

Sun, 21 Feb 2010 17:43:39 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Sun, 21 Feb 2010 17:43:39 +0500
changeset 2688
d0d38fcaade0
parent 2687
f9bc95aadc26
child 2689
542d633e0280
child 2691
2045d13ba018

mod_iq: Fire sub-events for iq/self events.

plugins/mod_iq.lua file | annotate | diff | comparison | revisions
--- a/plugins/mod_iq.lua	Sun Feb 21 17:43:05 2010 +0500
+++ b/plugins/mod_iq.lua	Sun Feb 21 17:43:39 2010 +0500
@@ -53,6 +53,18 @@
 	end
 end);
 
+module:hook("iq/self", function(data)
+	-- IQ to bare JID recieved
+	local origin, stanza = data.origin, data.stanza;
+
+	if stanza.attr.type == "get" or stanza.attr.type == "set" then
+		return module:fire_event("iq/self/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data);
+	else
+		module:fire_event("iq/self/"..stanza.attr.id, data);
+		return true;
+	end
+end);
+
 module:hook("iq/host", function(data)
 	-- IQ to a local host recieved
 	local origin, stanza = data.origin, data.stanza;

mercurial