plugins/mod_iq.lua
changeset 8731 41c959c5c84b
parent 5776 bd0ff8ae98a8
child 12981 74b9e05af71e
equal deleted inserted replaced
8730:285075a27f28 8731:41c959c5c84b
    11 
    11 
    12 local full_sessions = prosody.full_sessions;
    12 local full_sessions = prosody.full_sessions;
    13 
    13 
    14 if module:get_host_type() == "local" then
    14 if module:get_host_type() == "local" then
    15 	module:hook("iq/full", function(data)
    15 	module:hook("iq/full", function(data)
    16 		-- IQ to full JID recieved
    16 		-- IQ to full JID received
    17 		local origin, stanza = data.origin, data.stanza;
    17 		local origin, stanza = data.origin, data.stanza;
    18 
    18 
    19 		local session = full_sessions[stanza.attr.to];
    19 		local session = full_sessions[stanza.attr.to];
    20 		if not (session and session.send(stanza)) then
    20 		if not (session and session.send(stanza)) then
    21 			if stanza.attr.type == "get" or stanza.attr.type == "set" then
    21 			if stanza.attr.type == "get" or stanza.attr.type == "set" then
    25 		return true;
    25 		return true;
    26 	end);
    26 	end);
    27 end
    27 end
    28 
    28 
    29 module:hook("iq/bare", function(data)
    29 module:hook("iq/bare", function(data)
    30 	-- IQ to bare JID recieved
    30 	-- IQ to bare JID received
    31 	local stanza = data.stanza;
    31 	local stanza = data.stanza;
    32 	local type = stanza.attr.type;
    32 	local type = stanza.attr.type;
    33 
    33 
    34 	-- TODO fire post processing events
    34 	-- TODO fire post processing events
    35 	if type == "get" or type == "set" then
    35 	if type == "get" or type == "set" then
    42 		return module:fire_event("iq-"..type.."/bare/"..stanza.attr.id, data);
    42 		return module:fire_event("iq-"..type.."/bare/"..stanza.attr.id, data);
    43 	end
    43 	end
    44 end);
    44 end);
    45 
    45 
    46 module:hook("iq/self", function(data)
    46 module:hook("iq/self", function(data)
    47 	-- IQ to self JID recieved
    47 	-- IQ to self JID received
    48 	local stanza = data.stanza;
    48 	local stanza = data.stanza;
    49 	local type = stanza.attr.type;
    49 	local type = stanza.attr.type;
    50 
    50 
    51 	if type == "get" or type == "set" then
    51 	if type == "get" or type == "set" then
    52 		local child = stanza.tags[1];
    52 		local child = stanza.tags[1];
    58 		return module:fire_event("iq-"..type.."/self/"..stanza.attr.id, data);
    58 		return module:fire_event("iq-"..type.."/self/"..stanza.attr.id, data);
    59 	end
    59 	end
    60 end);
    60 end);
    61 
    61 
    62 module:hook("iq/host", function(data)
    62 module:hook("iq/host", function(data)
    63 	-- IQ to a local host recieved
    63 	-- IQ to a local host received
    64 	local stanza = data.stanza;
    64 	local stanza = data.stanza;
    65 	local type = stanza.attr.type;
    65 	local type = stanza.attr.type;
    66 
    66 
    67 	if type == "get" or type == "set" then
    67 	if type == "get" or type == "set" then
    68 		local child = stanza.tags[1];
    68 		local child = stanza.tags[1];