diff options
author | Waqas Hussain <waqas20@gmail.com> | 2008-10-23 19:47:56 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2008-10-23 19:47:56 +0500 |
commit | 2b81d8a673f98895b5950884b0daba876bb62e3b (patch) | |
tree | 05a69576ee080b8b9b789337698b4b52767ceb0b | |
parent | bf97de7a750ca14bd284ac3a8f3c56d2f5f6437c (diff) | |
download | prosody-2b81d8a673f98895b5950884b0daba876bb62e3b.tar.gz prosody-2b81d8a673f98895b5950884b0daba876bb62e3b.zip |
Presence fixes
- Presence to other resources sent correctly
- Resource of the recipient ignored for all presence except available and unavailable
-rw-r--r-- | core/stanza_router.lua | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/core/stanza_router.lua b/core/stanza_router.lua index 0d8c4fbe..3d53e797 100644 --- a/core/stanza_router.lua +++ b/core/stanza_router.lua @@ -12,7 +12,7 @@ local send = require "core.sessionmanager".send_to_session; 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 @@ function core_handle_stanza(origin, stanza) 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 @@ function core_route_stanza(origin, stanza) 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 |