aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-02-11 23:16:14 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-02-11 23:16:14 +0500
commit55223db764c36726db0bbf69ddff3703abe4bd1f (patch)
treeef9b622a06d1c504aeaad055d1491d451589c567 /core
parente711e847ddb176bb45b7c5a70cac99039a384aa7 (diff)
downloadprosody-55223db764c36726db0bbf69ddff3703abe4bd1f.tar.gz
prosody-55223db764c36726db0bbf69ddff3703abe4bd1f.zip
Stanza router: Message to bare JID fixes
- headline messages get sent to all non-negative priority available resource - all other messages get sent to the set of highest non-negative priority available resources - only messages of type chat and normal or missing type go into offline storage
Diffstat (limited to 'core')
-rw-r--r--core/stanza_router.lua49
1 files changed, 31 insertions, 18 deletions
diff --git a/core/stanza_router.lua b/core/stanza_router.lua
index c27a6579..f83619c6 100644
--- a/core/stanza_router.lua
+++ b/core/stanza_router.lua
@@ -34,6 +34,8 @@ local t_concat = table.concat;
local t_insert = table.insert;
local tonumber = tonumber;
local s_find = string.find;
+local pairs = pairs;
+local ipairs = ipairs;
local jid_split = require "util.jid".split;
local jid_prepped_split = require "util.jid".prepped_split;
@@ -208,25 +210,36 @@ function core_route_stanza(origin, stanza)
end
end
elseif stanza.name == "message" then -- select a resource to recieve message
- local priority = 0;
- local recipients = {};
- for _, session in pairs(user.sessions) do -- find resource with greatest priority
- local p = session.priority;
- if p > priority then
- priority = p;
- recipients = {session};
- elseif p == priority then
- t_insert(recipients, session);
+ if message.attr.type == 'headline' then
+ for _, session in pairs(user.sessions) do -- find resource with greatest priority
+ if session.presence and session.priority >= 0 then
+ stanza.attr.to = session.full_jid;
+ session.send(stanza);
+ end
+ end
+ else
+ local priority = 0;
+ local recipients = {};
+ for _, session in pairs(user.sessions) do -- find resource with greatest priority
+ if session.presence then
+ local p = session.priority;
+ if p > priority then
+ priority = p;
+ recipients = {session};
+ elseif p == priority then
+ t_insert(recipients, session);
+ end
+ end
+ end
+ local count = 0;
+ for _, session in ipairs(recipients) do
+ session.send(stanza);
+ count = count + 1;
+ end
+ if count == 0 and (stanza.attr.type == "chat" or stanza.attr.type == "normal" or not stanza.attr.type) then
+ offlinemanager.store(node, host, stanza);
+ -- TODO deal with storage errors
end
- end
- local count = 0;
- for _, session in pairs(recipients) do
- session.send(stanza);
- count = count + 1;
- end
- if count == 0 then
- offlinemanager.store(node, host, stanza);
- -- TODO deal with storage errors
end
else
-- TODO send IQ error