aboutsummaryrefslogtreecommitdiffstats
path: root/core/stanza_router.lua
diff options
context:
space:
mode:
Diffstat (limited to 'core/stanza_router.lua')
-rw-r--r--core/stanza_router.lua15
1 files changed, 10 insertions, 5 deletions
diff --git a/core/stanza_router.lua b/core/stanza_router.lua
index 37e8f176..fb5b2cbf 100644
--- a/core/stanza_router.lua
+++ b/core/stanza_router.lua
@@ -99,10 +99,10 @@ function core_process_stanza(origin, stanza)
core_handle_stanza(origin, stanza);
elseif stanza.attr.xmlns and stanza.attr.xmlns ~= "jabber:client" and stanza.attr.xmlns ~= "jabber:server" then
modules_handle_stanza(host or origin.host or origin.to_host, origin, stanza);
- elseif hosts[to_bare] and hosts[to_bare].type == "component" then -- hack to allow components to handle node@server
- component_handle_stanza(origin, stanza);
elseif hosts[to] and hosts[to].type == "component" then -- hack to allow components to handle node@server/resource and server/resource
component_handle_stanza(origin, stanza);
+ elseif hosts[to_bare] and hosts[to_bare].type == "component" then -- hack to allow components to handle node@server
+ component_handle_stanza(origin, stanza);
elseif hosts[host] and hosts[host].type == "component" then -- directed at a component
component_handle_stanza(origin, stanza);
elseif origin.type == "c2s" and stanza.name == "presence" and stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" then
@@ -110,6 +110,10 @@ function core_process_stanza(origin, stanza)
elseif origin.type ~= "c2s" and stanza.name == "iq" and not resource then -- directed at bare JID
core_handle_stanza(origin, stanza);
else
+ if origin.type == "c2s" and stanza.name == "presence" and to ~= nil and not(origin.roster[to_bare] and (origin.roster[to_bare].subscription == "both" or origin.roster[to_bare].subscription == "from")) then
+ origin.directed = origin.directed or {};
+ t_insert(origin.directed, to); -- FIXME does it make more sense to add to_bare rather than to?
+ end
core_route_stanza(origin, stanza);
end
else
@@ -225,7 +229,7 @@ function core_route_stanza(origin, stanza)
else
-- TODO send unavailable presence or unsubscribed
end
- elseif stanza.name == "message" then
+ elseif stanza.name == "message" then -- FIXME if full jid, then send out to resources with highest priority
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
@@ -233,12 +237,13 @@ function core_route_stanza(origin, stanza)
-- TODO allow configuration of offline storage
-- TODO send error if not storing offline
elseif stanza.name == "iq" then
- -- TODO send IQ error
+ 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
- if stanza.attr.type == "probe" 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