aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_presence.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2010-02-12 00:55:06 +0500
committerWaqas Hussain <waqas20@gmail.com>2010-02-12 00:55:06 +0500
commit60c40e44de335c4d7f6ed8b6ed25e8307bc4bcd9 (patch)
tree72216f938794c9fccba02d5dcbea8d257aeda056 /plugins/mod_presence.lua
parent1349805068792385931dceb72f6b6865c8fa88ac (diff)
downloadprosody-60c40e44de335c4d7f6ed8b6ed25e8307bc4bcd9.tar.gz
prosody-60c40e44de335c4d7f6ed8b6ed25e8307bc4bcd9.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.lua13
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