Software /
code /
prosody
Comparison
plugins/mod_iq.lua @ 1265:3f3c62e45eeb
mod_iq: Error reply for IQ to non-existing session. mod_iq now handles all 'iq/full' cases
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Mon, 01 Jun 2009 09:49:37 +0500 |
parent | 1260:04c1fae0eb03 |
child | 1266:605a73234230 |
comparison
equal
deleted
inserted
replaced
1264:498293bce4bf | 1265:3f3c62e45eeb |
---|---|
1 | |
2 local st = require "util.stanza"; | |
1 | 3 |
2 local full_sessions = full_sessions; | 4 local full_sessions = full_sessions; |
3 local bare_sessions = bare_sessions; | 5 local bare_sessions = bare_sessions; |
4 | 6 |
5 module:hook("iq/full", function(data) | 7 module:hook("iq/full", function(data) |
8 | 10 |
9 local session = full_sessions[stanza.attr.to]; | 11 local session = full_sessions[stanza.attr.to]; |
10 if session then | 12 if session then |
11 -- TODO fire post processing event | 13 -- TODO fire post processing event |
12 session.send(stanza); | 14 session.send(stanza); |
13 return true; | |
14 else -- resource not online | 15 else -- resource not online |
15 -- TODO error reply | 16 if stanza.attr.type == "get" or stanza.attr.type == "set" then |
17 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); | |
18 end | |
16 end | 19 end |
20 return true; | |
17 end); | 21 end); |
18 | 22 |
19 module:hook("iq/bare", function(data) | 23 module:hook("iq/bare", function(data) |
20 -- IQ to bare JID recieved | 24 -- IQ to bare JID recieved |
21 local origin, stanza = data.origin, data.stanza; | 25 local origin, stanza = data.origin, data.stanza; |