# HG changeset patch # User Waqas Hussain # Date 1230163095 -18000 # Node ID 658a2de74afcab34b18592ca4a161e297a45dbd3 # Parent 0681305633115855853040ddc1bf8ca2769adf1f Directed presence diff -r 068130563311 -r 658a2de74afc core/presencemanager.lua --- a/core/presencemanager.lua Thu Dec 25 04:27:19 2008 +0500 +++ b/core/presencemanager.lua Thu Dec 25 04:58:15 2008 +0500 @@ -103,7 +103,14 @@ end origin.priority = 0; if stanza.attr.type == "unavailable" then - origin.presence = nil; + origin.presence = nil; + if origin.directed then + for _, jid in ipairs(origin.directed) do + stanza.attr.to = jid; + core_route_stanza(origin, stanza); + end + origin.directed = nil; + end else origin.presence = stanza; local priority = stanza:child_with_name("priority"); diff -r 068130563311 -r 658a2de74afc core/stanza_router.lua --- a/core/stanza_router.lua Thu Dec 25 04:27:19 2008 +0500 +++ b/core/stanza_router.lua Thu Dec 25 04:58:15 2008 +0500 @@ -110,6 +110,10 @@ 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