sessionmanager: Rename filters_initialize->initialize_filters
[prosody.git] / core / stanza_router.lua
index 7ebfb2bb167bce1ad1d71c741158a90938992f89..d6dd53062d655ae59768b097a0c9b71d7c6d1a5e 100644 (file)
@@ -123,7 +123,7 @@ function core_post_stanza(origin, stanza, preevents)
        local node, host, resource = jid_split(to);
        local to_bare = node and (node.."@"..host) or host; -- bare JID
 
-       local to_type;
+       local to_type, to_self;
        if node then
                if resource then
                        to_type = '/full';
@@ -131,6 +131,7 @@ function core_post_stanza(origin, stanza, preevents)
                        to_type = '/bare';
                        if node == origin.username and host == origin.host then
                                stanza.attr.to = nil;
+                               to_self = true;
                        end
                end
        else
@@ -138,6 +139,7 @@ function core_post_stanza(origin, stanza, preevents)
                        to_type = '/host';
                else
                        to_type = '/bare';
+                       to_self = true;
                end
        end
 
@@ -148,6 +150,7 @@ function core_post_stanza(origin, stanza, preevents)
        local h = hosts[to_bare] or hosts[host or origin.host];
        if h then
                if h.events.fire_event(stanza.name..to_type, event_data) then return; end -- do processing
+               if to_self and h.events.fire_event(stanza.name..'/self', event_data) then return; end -- do processing
 
                if h.type == "component" then
                        component_handle_stanza(origin, stanza);
@@ -179,7 +182,7 @@ function core_route_stanza(origin, stanza)
                        local xmlns = stanza.attr.xmlns;
                        --stanza.attr.xmlns = "jabber:server";
                        stanza.attr.xmlns = nil;
-                       log("debug", "sending s2s stanza: %s", tostring(stanza));
+                       log("debug", "sending s2s stanza: %s", tostring(stanza.top_tag and stanza:top_tag()) or stanza);
                        send_s2s(origin.host, host, stanza); -- TODO handle remote routing errors
                        stanza.attr.xmlns = xmlns; -- reset
                else