aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2010-02-12 00:54:14 +0500
committerWaqas Hussain <waqas20@gmail.com>2010-02-12 00:54:14 +0500
commit1349805068792385931dceb72f6b6865c8fa88ac (patch)
treef9f9fa3a04a799e25997b9d1cb2b71f1e5876305
parente376e12502db674b55e1fe29e376225462f3a1fb (diff)
downloadprosody-1349805068792385931dceb72f6b6865c8fa88ac.tar.gz
prosody-1349805068792385931dceb72f6b6865c8fa88ac.zip
mod_presence: Don't depend on sessions array existing for a user when handling outgoing presence broadcast.
-rw-r--r--plugins/mod_presence.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/plugins/mod_presence.lua b/plugins/mod_presence.lua
index c28dd338..4aa8f497 100644
--- a/plugins/mod_presence.lua
+++ b/plugins/mod_presence.lua
@@ -18,6 +18,7 @@ local st = require "util.stanza";
local jid_split = require "util.jid".split;
local jid_bare = require "util.jid".bare;
local hosts = hosts;
+local NULL = {};
local rostermanager = require "core.rostermanager";
local sessionmanager = require "core.sessionmanager";
@@ -63,7 +64,8 @@ end
function handle_normal_presence(origin, stanza, core_route_stanza)
local roster = origin.roster;
local node, host = origin.username, origin.host;
- for _, res in pairs(hosts[host].sessions[node].sessions) do -- broadcast to all resources
+ local user = bare_sessions[node.."@"..host];
+ for _, res in pairs(user and user.sessions or NULL) do -- broadcast to all resources
if res ~= origin and res.presence then -- to resource
stanza.attr.to = res.full_jid;
core_route_stanza(origin, stanza);
@@ -84,7 +86,7 @@ function handle_normal_presence(origin, stanza, core_route_stanza)
core_route_stanza(origin, probe);
end
end
- for _, res in pairs(hosts[host].sessions[node].sessions) do -- broadcast from all available resources
+ for _, res in pairs(user and user.sessions or NULL) do -- broadcast from all available resources
if res ~= origin and res.presence then
res.presence.attr.to = origin.full_jid;
core_route_stanza(res, res.presence);