Changeset

3786:28d9fff67fed

mod_iq: Extra IQ get and set sub-events are now fired: "iq-{get,set}/{host,self,bare}/xmlns:tag" (when "iq/{host,self,bare}/xmlns:tag" is unhandled).
author Waqas Hussain <waqas20@gmail.com>
date Sun, 28 Nov 2010 02:24:26 +0500
parents 3785:374a1a680065
children 3787:95aaf9fc5a6c
files plugins/mod_iq.lua
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_iq.lua	Sat Nov 27 21:52:30 2010 +0000
+++ b/plugins/mod_iq.lua	Sun Nov 28 02:24:26 2010 +0500
@@ -35,7 +35,9 @@
 
 	-- TODO fire post processing events
 	if stanza.attr.type == "get" or stanza.attr.type == "set" then
-		return module:fire_event("iq/bare/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data);
+		local ret = module:fire_event("iq/bare/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data);
+		if ret ~= nil then return ret; end
+		return module:fire_event("iq-"..stanza.attr.type.."/bare/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data);
 	else
 		module:fire_event("iq-"..stanza.attr.type.."/bare/"..stanza.attr.id, data);
 		return true;
@@ -43,11 +45,13 @@
 end);
 
 module:hook("iq/self", function(data)
-	-- IQ to bare JID recieved
+	-- IQ to self 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);
+		local ret = module:fire_event("iq/self/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data);
+		if ret ~= nil then return ret; end
+		return module:fire_event("iq-"..stanza.attr.type.."/self/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data);
 	else
 		module:fire_event("iq-"..stanza.attr.type.."/self/"..stanza.attr.id, data);
 		return true;
@@ -59,7 +63,9 @@
 	local origin, stanza = data.origin, data.stanza;
 
 	if stanza.attr.type == "get" or stanza.attr.type == "set" then
-		return module:fire_event("iq/host/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data);
+		local ret = module:fire_event("iq/host/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data);
+		if ret ~= nil then return ret; end
+		return module:fire_event("iq-"..stanza.attr.type.."/host/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data);
 	else
 		module:fire_event("iq-"..stanza.attr.type.."/host/"..stanza.attr.id, data);
 		return true;