Software /
code /
prosody
Diff
core/stanza_router.lua @ 130:907cff6b5359
Presence fixes
- Presence to other resources sent correctly
- Resource of the recipient ignored for all presence except available and unavailable
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Thu, 23 Oct 2008 19:47:56 +0500 |
parent | 128:77a1778b16e8 |
child | 135:bf10d42dd41b |
line wrap: on
line diff
--- 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