# HG changeset patch # User Waqas Hussain # Date 1224773276 -18000 # Node ID 907cff6b5359de35154b1b33c6912c78f508dab7 # Parent 0f119bece3097d751cb84048bd08e9875d453609 Presence fixes - Presence to other resources sent correctly - Resource of the recipient ignored for all presence except available and unavailable diff -r 0f119bece309 -r 907cff6b5359 core/stanza_router.lua --- a/core/stanza_router.lua Thu Oct 23 18:42:29 2008 +0500 +++ b/core/stanza_router.lua Thu Oct 23 19:47:56 2008 +0500 @@ -12,7 +12,7 @@ local user_exists = require "core.usermanager".user_exists; local jid_split = require "util.jid".split; -local print = print; +local print, debug = print, debug; function core_process_stanza(origin, stanza) log("debug", "Received: "..tostring(stanza)) @@ -63,13 +63,20 @@ core_route_stanza(origin, stanza); end end - --[[local node, host = jid_split(stanza.attr.from); - for _, res in pairs(hosts[host].sessions[node].sessions) do -- broadcast to all resources - if res.full_jid then - res = user.sessions[k]; - break; + local node, host = jid_split(stanza.attr.from); + for _, res in pairs(hosts[host].sessions[node].sessions) do -- broadcast to all resources and from resources + if res ~= origin then + if res.full_jid then -- to resource. FIXME is this check correct? Maybe it should be res.presence + stanza.attr.to = res.full_jid; + core_route_stanza(origin, stanza); + end + if res.presence then -- from all resources for which we have presence + res.presence.attr.to = origin.full_jid; + core_route_stanza(res, res.presence); + res.presence.attr.to = nil; + end end - end]] + end if not origin.presence then -- presence probes on initial presence local probe = st.presence({from = origin.full_jid, type = "probe"}); for jid in pairs(origin.roster) do @@ -106,7 +113,7 @@ local to = stanza.attr.to; local node, host, resource = jid_split(to); - if stanza.name == "presence" and stanza.attr.type == "probe" then resource = nil; end + if stanza.name == "presence" and (stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable") then resource = nil; end local host_session = hosts[host] if host_session and host_session.type == "local" then