diff options
author | Waqas Hussain <waqas20@gmail.com> | 2010-02-12 00:55:06 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2010-02-12 00:55:06 +0500 |
commit | 763b4d3fc7307f5c500d5e26cb6a3bcaaabb0439 (patch) | |
tree | e896a3f92923c8d1523a2140d18f5c2c8876c091 /plugins/mod_presence.lua | |
parent | 199d21bfc8004f11893d7d059a24bc52d8064beb (diff) | |
download | prosody-763b4d3fc7307f5c500d5e26cb6a3bcaaabb0439.tar.gz prosody-763b4d3fc7307f5c500d5e26cb6a3bcaaabb0439.zip |
mod_presence: Don't depend on user being online when calculating top resources.
Diffstat (limited to 'plugins/mod_presence.lua')
-rw-r--r-- | plugins/mod_presence.lua | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/plugins/mod_presence.lua b/plugins/mod_presence.lua index 4aa8f497..f6ea9e6b 100644 --- a/plugins/mod_presence.lua +++ b/plugins/mod_presence.lua @@ -55,10 +55,11 @@ local function select_top_resources(user) end return recipients; end -local function recalc_resource_map(origin) - local user = hosts[origin.host].sessions[origin.username]; - user.top_resources = select_top_resources(user); - if #user.top_resources == 0 then user.top_resources = nil; end +local function recalc_resource_map(user) + if user then + user.top_resources = select_top_resources(user); + if #user.top_resources == 0 then user.top_resources = nil; end + end end function handle_normal_presence(origin, stanza, core_route_stanza) @@ -117,7 +118,7 @@ function handle_normal_presence(origin, stanza, core_route_stanza) origin.presence = nil; if origin.priority then origin.priority = nil; - recalc_resource_map(origin); + recalc_resource_map(user); end if origin.directed then for jid in pairs(origin.directed) do @@ -139,7 +140,7 @@ function handle_normal_presence(origin, stanza, core_route_stanza) else priority = 0; end if origin.priority ~= priority then origin.priority = priority; - recalc_resource_map(origin); + recalc_resource_map(user); end end stanza.attr.to = nil; -- reset it |