Added discohelper
[prosody.git] / core / stanza_router.lua
index 46ece139a339152e2f4a5cc2174ed57a18cf15c4..2505fca3cfc759dddb0ef1db33119524af1db88d 100644 (file)
@@ -191,7 +191,7 @@ function core_handle_stanza(origin, stanza)
                log("warn", "Unhandled origin: %s", origin.type);
                if (stanza.attr.xmlns == "jabber:client" or stanza.attr.xmlns == "jabber:server") and stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then
                        -- s2s stanzas can get here
-                       (origin.sends2s or origin.send)(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error?
+                       origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- FIXME correct error?
                end
        end
 end
@@ -208,6 +208,10 @@ function core_route_stanza(origin, stanza)
        local from_node, from_host, from_resource = jid_split(from);
        local from_bare = from_node and (from_node.."@"..from_host) or from_host; -- bare JID
 
+       -- Auto-detect origin if not specified
+       origin = origin or hosts[from_host];
+       if not origin then return false; end
+       
        if stanza.name == "presence" and (stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable") then resource = nil; end
 
        local host_session = hosts[host]
@@ -300,8 +304,6 @@ function core_route_stanza(origin, stanza)
        elseif origin.type == "component" or origin.type == "local" then
                -- Route via s2s for components and modules
                log("debug", "Routing outgoing stanza for %s to %s", origin.host, host);
-               for k,v in pairs(origin) do print("origin:", tostring(k), tostring(v)); end
-               print(tostring(host), tostring(from_host))
                send_s2s(origin.host, host, stanza);
        else
                log("warn", "received stanza from unhandled connection type: %s", origin.type);