aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_message.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-06-26 08:54:22 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-06-26 08:54:22 +0500
commit03164502385bf737faed58ba494670296ff852f4 (patch)
tree6f67ad7239c938e9cd2b19fae482908f932e4bf9 /plugins/mod_message.lua
parentd9a71da2205b437903f52f517e3c6bc72eebd59a (diff)
downloadprosody-03164502385bf737faed58ba494670296ff852f4.tar.gz
prosody-03164502385bf737faed58ba494670296ff852f4.zip
mod_message, mod_presence: Maintain list of top resources. Less work in routing messages to bare JIDs. - #optimization
Diffstat (limited to 'plugins/mod_message.lua')
-rw-r--r--plugins/mod_message.lua22
1 files changed, 2 insertions, 20 deletions
diff --git a/plugins/mod_message.lua b/plugins/mod_message.lua
index 048a578d..72ccfdd0 100644
--- a/plugins/mod_message.lua
+++ b/plugins/mod_message.lua
@@ -9,24 +9,6 @@ local user_exists = require "core.usermanager".user_exists;
local offlinemanager = require "core.offlinemanager";
local t_insert = table.insert;
-local function select_top_resources(user)
- local priority = 0;
- local recipients = {};
- for _, session in pairs(user.sessions) do -- find resource with greatest priority
- if session.presence then
- -- TODO check active privacy list for session
- local p = session.priority;
- if p > priority then
- priority = p;
- recipients = {session};
- elseif p == priority then
- t_insert(recipients, session);
- end
- end
- end
- return recipients;
-end
-
local function process_to_bare(bare, origin, stanza)
local user = bare_sessions[bare];
@@ -45,8 +27,8 @@ local function process_to_bare(bare, origin, stanza)
end -- current policy is to discard headlines if no recipient is available
else -- chat or normal message
if user then -- some resources are connected
- local recipients = select_top_resources(user);
- if #recipients > 0 then
+ local recipients = user.top_resources;
+ if recipients then
for i=1,#recipients do
recipients[i].send(stanza);
end