# HG changeset patch # User Waqas Hussain # Date 1265918054 -18000 # Node ID 3af266f7037f675b259b1728a4991d23801e3540 # Parent d540a75a11db87354a76a256c2a72432c58e9dd8 mod_presence: Don't depend on sessions array existing for a user when handling outgoing presence broadcast. diff -r d540a75a11db -r 3af266f7037f plugins/mod_presence.lua --- a/plugins/mod_presence.lua Thu Feb 11 19:34:23 2010 +0000 +++ b/plugins/mod_presence.lua Fri Feb 12 00:54:14 2010 +0500 @@ -18,6 +18,7 @@ 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 @@ 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 @@ 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);