Software /
code /
prosody
Changeset
2644:c75c22c316d6
mod_presence: Added config option 'bare_message_delivery_policy'. Allowed values are 'priority' (default) and 'broadcast'.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Mon, 15 Feb 2010 08:04:25 +0500 |
parents | 2643:21eb99b06f4d |
children | 2645:625d02b2a1a0 3082:920cd9667c7b |
files | plugins/mod_presence.lua |
diffstat | 1 files changed, 30 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_presence.lua Mon Feb 15 04:15:37 2010 +0500 +++ b/plugins/mod_presence.lua Mon Feb 15 08:04:25 2010 +0500 @@ -38,23 +38,42 @@ _core_route_stanza(origin, stanza); end -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 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 p = session.priority; - if p > priority then - priority = p; - recipients = {session}; - elseif p == priority then + if p and p >= 0 then t_insert(recipients, session); end end + return recipients; end - return recipients; +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 end + local function recalc_resource_map(user) if user then user.top_resources = select_top_resources(user);