# HG changeset patch # User Waqas Hussain # Date 1224768970 -18000 # Node ID 77a1778b16e81874d2870334f4076a10d3f452fa # Parent 74e5919e4737d687f3112efcb0eda28618b2e685 Set things up for presence subscriptions. Remove reference to core.s2smanager. diff -r 74e5919e4737 -r 77a1778b16e8 core/stanza_router.lua --- a/core/stanza_router.lua Thu Oct 23 04:06:51 2008 +0100 +++ b/core/stanza_router.lua Thu Oct 23 18:36:10 2008 +0500 @@ -9,7 +9,6 @@ local st = require "util.stanza"; local send = require "core.sessionmanager".send_to_session; -local send_s2s = require "core.s2smanager".send_to_host; local user_exists = require "core.usermanager".user_exists; local jid_split = require "util.jid".split; @@ -118,22 +117,32 @@ if not res then -- if we get here, resource was not specified or was unavailable if stanza.name == "presence" then - if stanza.attr.type == "probe" then - if is_authorized_to_see_presence(origin, node, host) then - for k in pairs(user.sessions) do -- return presence for all resources - if user.sessions[k].presence then - local pres = user.sessions[k].presence; - pres.attr.to = origin.full_jid; - pres.attr.from = user.sessions[k].full_jid; - send(origin, pres); - pres.attr.to = nil; - pres.attr.from = nil; + if stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" then + if stanza.attr.type == "probe" then + if is_authorized_to_see_presence(origin, node, host) then + for k in pairs(user.sessions) do -- return presence for all resources + if user.sessions[k].presence then + local pres = user.sessions[k].presence; + pres.attr.to = origin.full_jid; + pres.attr.from = user.sessions[k].full_jid; + send(origin, pres); + pres.attr.to = nil; + pres.attr.from = nil; + end end + else + send(origin, st.presence({from=user.."@"..host, to=origin.username.."@"..origin.host, type="unsubscribed"})); end - else - send(origin, st.presence({from = user.."@"..host, to = origin.username.."@"..origin.host, type = "unsubscribed"})); - end - else + elseif stanza.attr.type == "subscribe" then + -- TODO + elseif stanza.attr.type == "unsubscribe" then + -- TODO + elseif stanza.attr.type == "subscribed" then + -- TODO + elseif stanza.attr.type == "unsubscribed" then + -- TODO + end -- discard any other type + else -- sender is available or unavailable for k in pairs(user.sessions) do -- presence broadcast to all user resources if user.sessions[k].full_jid then stanza.attr.to = user.sessions[k].full_jid;