diff options
author | Waqas Hussain <waqas20@gmail.com> | 2009-06-25 07:57:57 +0500 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2009-06-25 07:57:57 +0500 |
commit | 67560bdcc6c100eee31b2c2e6d04c7acfff20ce4 (patch) | |
tree | 30ea66b80ce70868ba4e1d8ebb9cce4f74f187d0 /core/stanza_router.lua | |
parent | 386d7fa9266f96a36455ee0cbf3fc7859b63ce95 (diff) | |
download | prosody-67560bdcc6c100eee31b2c2e6d04c7acfff20ce4.tar.gz prosody-67560bdcc6c100eee31b2c2e6d04c7acfff20ce4.zip |
stanza_router: Removed old routing code
Diffstat (limited to 'core/stanza_router.lua')
-rw-r--r-- | core/stanza_router.lua | 83 |
1 files changed, 1 insertions, 82 deletions
diff --git a/core/stanza_router.lua b/core/stanza_router.lua index e5454119..6dc667fc 100644 --- a/core/stanza_router.lua +++ b/core/stanza_router.lua @@ -213,88 +213,7 @@ function core_route_stanza(origin, stanza) local host_session = hosts[host] if host_session and host_session.type == "local" then - -- Local host - local user = host_session.sessions[node]; - if user then - local res = user.sessions[resource]; - if res then -- resource is online... - res.send(stanza); -- Yay \o/ - else - -- if we get here, resource was not specified or was unavailable - if stanza.name == "presence" then - if stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" and stanza.attr.type ~= "error" then - -- inbound presence subscriptions and probes, already handled, so should never get here - elseif not resource then -- sender is available or unavailable or error - for _, session in pairs(user.sessions) do -- presence broadcast to all user resources. - if session.full_jid then -- FIXME should this be just for available resources? Do we need to check subscription? - stanza.attr.to = session.full_jid; -- reset at the end of function - session.send(stanza); - end - end - end - elseif stanza.name == "message" then -- select a resource to recieve message - stanza.attr.to = to_bare; - if stanza.attr.type == 'headline' then - for _, session in pairs(user.sessions) do -- find resource with greatest priority - if session.presence and session.priority >= 0 then - session.send(stanza); - end - end - elseif stanza.attr.type == 'groupchat' then - -- Groupchat message sent to offline resource - origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); - else - local count = 0; - for _, session in ipairs(select_best_resources(user)) do - session.send(stanza); - count = count + 1; - end - if count == 0 and (stanza.attr.type == "chat" or stanza.attr.type == "normal" or not stanza.attr.type) then - offlinemanager.store(node, host, stanza); - -- TODO deal with storage errors - end - end - elseif stanza.attr.type == "get" or stanza.attr.type == "set" then - origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); - end - end - else - -- user not online - if user_exists(node, host) then - if stanza.name == "presence" then - if stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" and stanza.attr.type ~= "error" then - -- inbound presence subscriptions and probes, already handled, so should never get here - else - -- TODO send unavailable presence or unsubscribed - end - elseif stanza.name == "message" then -- FIXME if full jid, then send out to resources with highest priority - stanza.attr.to = to_bare; -- TODO not in RFC, but seems obvious. Should discuss on the mailing list. - if stanza.attr.type == "chat" or stanza.attr.type == "normal" or not stanza.attr.type then - offlinemanager.store(node, host, stanza); - -- FIXME don't store messages with only chat state notifications - elseif stanza.attr.type == "groupchat" then - local reply = st.error_reply(stanza, "cancel", "service-unavailable"); - reply.attr.from = to; - origin.send(reply); - end - -- TODO allow configuration of offline storage - -- TODO send error if not storing offline - elseif stanza.name == "iq" and (stanza.attr.type == "get" or stanza.attr.type == "set") then - origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); - end - else -- user does not exist - -- TODO we would get here for nodeless JIDs too. Do something fun maybe? Echo service? Let plugins use xmpp:server/resource addresses? - if stanza.name == "presence" then - local t = stanza.attr.type; - if t == "subscribe" or t == "probe" then - origin.send(st.presence({from = to_bare, to = from_bare, type = "unsubscribed"})); - end - -- else ignore - elseif stanza.attr.type ~= "error" and (stanza.name ~= "iq" or stanza.attr.type ~= "result") then - origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); - end - end - end + -- old stanza routing code removed elseif origin.type == "c2s" then -- Remote host local xmlns = stanza.attr.xmlns; |