|
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 |
|
8 module:hook("message/full", function(data) |
|
9 -- message to full JID recieved |
|
10 local origin, stanza = data.origin, data.stanza; |
|
11 |
|
12 local session = full_sessions[stanza.attr.to]; |
|
13 if session then |
|
14 -- TODO fire post processing event |
|
15 session.send(stanza); |
|
16 return true; |
|
17 else -- resource not online |
|
18 -- TODO fire event to send to bare JID |
|
19 end |
|
20 end); |
|
21 |
|
22 module:hook("message/bare", function(data) |
|
23 -- message to bare JID recieved |
|
24 local origin, stanza = data.origin, data.stanza; |
|
25 |
|
26 local sessions = bare_sessoins[stanza.attr.to]; |
|
27 if sessions then sessions = sessions.sessions; end |
|
28 |
|
29 if sessions then |
|
30 -- some resources are online |
|
31 -- TODO find top resources willing to accept this message |
|
32 -- TODO then send them each the stanza |
|
33 else |
|
34 -- no resources are online |
|
35 -- TODO check if the user exists |
|
36 -- TODO if it doesn't, return an error reply |
|
37 -- TODO otherwise, apply the default privacy list |
|
38 -- TODO and store into offline storage |
|
39 -- TODO or maybe the offline store can apply privacy lists |
|
40 end |
|
41 end); |