author | Waqas Hussain <waqas20@gmail.com> |
Mon, 01 Jun 2009 05:35:32 +0500 | |
changeset 1260 | 04c1fae0eb03 |
parent 1234 | 0ff02499f05c |
child 1265 | 3f3c62e45eeb |
permissions | -rw-r--r-- |
1234
0ff02499f05c
mod_message, mod_iq: A little cleanup
Waqas Hussain <waqas20@gmail.com>
parents:
1233
diff
changeset
|
1 |
|
0ff02499f05c
mod_message, mod_iq: A little cleanup
Waqas Hussain <waqas20@gmail.com>
parents:
1233
diff
changeset
|
2 |
local full_sessions = full_sessions; |
0ff02499f05c
mod_message, mod_iq: A little cleanup
Waqas Hussain <waqas20@gmail.com>
parents:
1233
diff
changeset
|
3 |
local bare_sessions = bare_sessions; |
1233 | 4 |
|
5 |
module:hook("iq/full", function(data) |
|
6 |
-- IQ to full JID recieved |
|
7 |
local origin, stanza = data.origin, data.stanza; |
|
8 |
||
9 |
local session = full_sessions[stanza.attr.to]; |
|
10 |
if session then |
|
11 |
-- TODO fire post processing event |
|
12 |
session.send(stanza); |
|
13 |
return true; |
|
14 |
else -- resource not online |
|
15 |
-- TODO error reply |
|
16 |
end |
|
17 |
end); |
|
18 |
||
19 |
module:hook("iq/bare", function(data) |
|
20 |
-- IQ to bare JID recieved |
|
21 |
local origin, stanza = data.origin, data.stanza; |
|
22 |
||
23 |
-- TODO if not user exists, return an error |
|
24 |
-- TODO fire post processing events |
|
1260
04c1fae0eb03
mod_iq: Fire sub-events for IQs directed at bare JIDs and hosts
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
25 |
if #stanza.tags == 1 then |
04c1fae0eb03
mod_iq: Fire sub-events for IQs directed at bare JIDs and hosts
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
26 |
return module:fire_event("iq/bare/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name); |
04c1fae0eb03
mod_iq: Fire sub-events for IQs directed at bare JIDs and hosts
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
27 |
else |
04c1fae0eb03
mod_iq: Fire sub-events for IQs directed at bare JIDs and hosts
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
28 |
return true; -- TODO do something with results and errors |
04c1fae0eb03
mod_iq: Fire sub-events for IQs directed at bare JIDs and hosts
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
29 |
end |
1233 | 30 |
end); |
31 |
||
32 |
module:hook("iq/host", function(data) |
|
33 |
-- IQ to a local host recieved |
|
34 |
local origin, stanza = data.origin, data.stanza; |
|
35 |
||
1260
04c1fae0eb03
mod_iq: Fire sub-events for IQs directed at bare JIDs and hosts
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
36 |
if #stanza.tags == 1 then |
04c1fae0eb03
mod_iq: Fire sub-events for IQs directed at bare JIDs and hosts
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
37 |
return module:fire_event("iq/host/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name); |
04c1fae0eb03
mod_iq: Fire sub-events for IQs directed at bare JIDs and hosts
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
38 |
else |
04c1fae0eb03
mod_iq: Fire sub-events for IQs directed at bare JIDs and hosts
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
39 |
return true; -- TODO do something with results and errors |
04c1fae0eb03
mod_iq: Fire sub-events for IQs directed at bare JIDs and hosts
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
40 |
end |
1233 | 41 |
end); |