# HG changeset patch # User Waqas Hussain # Date 1234357781 -18000 # Node ID 4417ab6ccc207b1a138a0402bcc50a86802c75ef # Parent ec0eadf4e9ffe82ac08e9e65cc99343a78922505 Fixed directed presence handling to work correctly for components diff -r ec0eadf4e9ff -r 4417ab6ccc20 core/presencemanager.lua --- a/core/presencemanager.lua Wed Feb 11 18:07:20 2009 +0500 +++ b/core/presencemanager.lua Wed Feb 11 18:09:41 2009 +0500 @@ -97,7 +97,7 @@ if stanza.attr.type == "unavailable" then origin.presence = nil; if origin.directed then - for _, jid in ipairs(origin.directed) do + for jid in pairs(origin.directed) do stanza.attr.to = jid; core_route_stanza(origin, stanza); end diff -r ec0eadf4e9ff -r 4417ab6ccc20 core/stanza_router.lua --- a/core/stanza_router.lua Wed Feb 11 18:07:20 2009 +0500 +++ b/core/stanza_router.lua Wed Feb 11 18:09:41 2009 +0500 @@ -105,6 +105,11 @@ return; -- FIXME what should we do here? does this work with subdomains? end end + if origin.type == "c2s" and stanza.name == "presence" and to ~= nil and not(origin.roster[to_bare] and (origin.roster[to_bare].subscription == "both" or origin.roster[to_bare].subscription == "from")) then -- directed presence + origin.directed = origin.directed or {}; + origin.directed[to] = true; + --t_insert(origin.directed, to); -- FIXME does it make more sense to add to_bare rather than to? + end if not to then core_handle_stanza(origin, stanza); elseif hosts[to] and hosts[to].type == "local" then -- directed at a local server @@ -122,10 +127,6 @@ elseif origin.type ~= "c2s" and stanza.name == "iq" and not resource then -- directed at bare JID core_handle_stanza(origin, stanza); else - if origin.type == "c2s" and stanza.name == "presence" and to ~= nil and not(origin.roster[to_bare] and (origin.roster[to_bare].subscription == "both" or origin.roster[to_bare].subscription == "from")) then - origin.directed = origin.directed or {}; - t_insert(origin.directed, to); -- FIXME does it make more sense to add to_bare rather than to? - end core_route_stanza(origin, stanza); end else