author | Waqas Hussain <waqas20@gmail.com> |
Mon, 01 Jun 2009 17:36:33 +0500 | |
changeset 1271 | e78c161944ab |
parent 1234 | 0ff02499f05c |
child 1272 | 28f9041d8c55 |
permissions | -rw-r--r-- |
1232 | 1 |
|
2 |
local full_sessions = full_sessions; |
|
3 |
local bare_sessions = bare_sessions; |
|
4 |
||
5 |
local jid_bare = require "util.jid".bare; |
|
6 |
local user_exists = require "core.usermanager".user_exists; |
|
7 |
||
1271
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
8 |
local function process_to_bare(bare, origin, stanza) |
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
9 |
local sessions = bare_sessions[bare]; |
1232 | 10 |
if sessions then sessions = sessions.sessions; end |
11 |
||
12 |
if sessions then |
|
13 |
-- some resources are online |
|
14 |
-- TODO find top resources willing to accept this message |
|
15 |
-- TODO then send them each the stanza |
|
16 |
else |
|
17 |
-- no resources are online |
|
18 |
-- TODO check if the user exists |
|
19 |
-- TODO if it doesn't, return an error reply |
|
20 |
-- TODO otherwise, apply the default privacy list |
|
21 |
-- TODO and store into offline storage |
|
22 |
-- TODO or maybe the offline store can apply privacy lists |
|
23 |
end |
|
1271
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
24 |
end |
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
25 |
|
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
26 |
module:hook("message/full", function(data) |
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
27 |
-- message to full JID recieved |
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
28 |
local origin, stanza = data.origin, data.stanza; |
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
29 |
|
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
30 |
local session = full_sessions[stanza.attr.to]; |
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
31 |
if session then |
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
32 |
-- TODO fire post processing event |
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
33 |
session.send(stanza); |
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
34 |
return true; |
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
35 |
else -- resource not online |
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
36 |
return process_to_bare(jid_bare(stanza.attr.to), origin, stanza); |
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
37 |
end |
1232 | 38 |
end); |
1271
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
39 |
|
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
40 |
module:hook("message/bare", function(data) |
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
41 |
-- message to bare JID recieved |
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
42 |
local origin, stanza = data.origin, data.stanza; |
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
43 |
|
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
44 |
return process_to_bare(stanza.attr.to or (origin.username..'@'..origin.host), origin, stanza); |
e78c161944ab
mod_message: Move bare JID processing to it's own function
Waqas Hussain <waqas20@gmail.com>
parents:
1234
diff
changeset
|
45 |
end); |