aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_presence.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-05-21 19:44:31 +0100
committerMatthew Wild <mwild1@gmail.com>2010-05-21 19:44:31 +0100
commit017a5331582d4dbdf0512547491c0a680db3afb2 (patch)
tree1bfce66d5a97b36cb0edbe06ea84e5c9ff910f7d /plugins/mod_presence.lua
parentfdcf472ada6f666a690ce73d77cf173c09fc3dc6 (diff)
downloadprosody-017a5331582d4dbdf0512547491c0a680db3afb2.tar.gz
prosody-017a5331582d4dbdf0512547491c0a680db3afb2.zip
Backed out changeset c75c22c316d6 (the XMPP spec now gives a better way to do this)
Diffstat (limited to 'plugins/mod_presence.lua')
-rw-r--r--plugins/mod_presence.lua41
1 files changed, 11 insertions, 30 deletions
diff --git a/plugins/mod_presence.lua b/plugins/mod_presence.lua
index 648c78b3..a39d9c19 100644
--- a/plugins/mod_presence.lua
+++ b/plugins/mod_presence.lua
@@ -38,42 +38,23 @@ function core_route_stanza(origin, stanza)
_core_route_stanza(origin, stanza);
end
-local select_top_resources;
-local bare_message_delivery_policy = module:get_option("bare_message_delivery_policy") or "priority";
-if bare_message_delivery_policy == "broadcast" then
- function select_top_resources(user)
- local recipients = {};
- for _, session in pairs(user.sessions) do -- find resources with non-negative priority
+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 and p >= 0 then
+ if p > priority then
+ priority = p;
+ recipients = {session};
+ elseif p == priority then
t_insert(recipients, session);
end
end
- return recipients;
- end
-else
- if bare_message_delivery_policy ~= "priority" then
- module:log("warn", "Invalid value for config option bare_message_delivery_policy");
- end
- 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
+ return recipients;
end
-
local function recalc_resource_map(user)
if user then
user.top_resources = select_top_resources(user);