Annotate

plugins/mod_message.lua @ 1261:497178e0ddbe

Automated merge with http://waqas.ath.cx:8000/
author Matthew Wild <mwild1@gmail.com>
date Mon, 01 Jun 2009 01:36:42 +0100
parent 1234:0ff02499f05c
child 1271:e78c161944ab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1232
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
1
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
2 local full_sessions = full_sessions;
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
3 local bare_sessions = bare_sessions;
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
4
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
5 local jid_bare = require "util.jid".bare;
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
6 local user_exists = require "core.usermanager".user_exists;
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
7
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
8 module:hook("message/full", function(data)
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
9 -- message to full JID recieved
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
10 local origin, stanza = data.origin, data.stanza;
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
11
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
12 local session = full_sessions[stanza.attr.to];
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
13 if session then
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
14 -- TODO fire post processing event
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
15 session.send(stanza);
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
16 return true;
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
17 else -- resource not online
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
18 -- TODO fire event to send to bare JID
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
19 end
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
20 end);
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
21
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
22 module:hook("message/bare", function(data)
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
23 -- message to bare JID recieved
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
24 local origin, stanza = data.origin, data.stanza;
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
25
1234
0ff02499f05c mod_message, mod_iq: A little cleanup
Waqas Hussain <waqas20@gmail.com>
parents: 1232
diff changeset
26 local sessions = bare_sessions[stanza.attr.to];
1232
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
27 if sessions then sessions = sessions.sessions; end
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
28
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
29 if sessions then
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
30 -- some resources are online
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
31 -- TODO find top resources willing to accept this message
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
32 -- TODO then send them each the stanza
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
33 else
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
34 -- no resources are online
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
35 -- TODO check if the user exists
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
36 -- TODO if it doesn't, return an error reply
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
37 -- TODO otherwise, apply the default privacy list
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
38 -- TODO and store into offline storage
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
39 -- TODO or maybe the offline store can apply privacy lists
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
40 end
6ddbb583f067 mod_message: Initial commit
Waqas Hussain <waqas20@gmail.com>
parents:
diff changeset
41 end);