2 local st = require "util.stanza";
4 local full_sessions = full_sessions;
5 local bare_sessions = bare_sessions;
7 module:hook("iq/full", function(data)
8 -- IQ to full JID recieved
9 local origin, stanza = data.origin, data.stanza;
11 local session = full_sessions[stanza.attr.to];
13 -- TODO fire post processing event
15 else -- resource not online
16 if stanza.attr.type == "get" or stanza.attr.type == "set" then
17 origin.send(st.error_reply(stanza, "cancel", "service-unavailable"));
23 module:hook("iq/bare", function(data)
24 -- IQ to bare JID recieved
25 local origin, stanza = data.origin, data.stanza;
27 -- TODO if not user exists, return an error
28 -- TODO fire post processing events
29 if #stanza.tags == 1 then
30 return module:fire_event("iq/bare/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name);
32 return true; -- TODO do something with results and errors
36 module:hook("iq/host", function(data)
37 -- IQ to a local host recieved
38 local origin, stanza = data.origin, data.stanza;
40 if #stanza.tags == 1 then
41 return module:fire_event("iq/host/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name);
43 return true; -- TODO do something with results and errors