mod_presence: return true from the presence handler
[prosody.git] / plugins / mod_presence.lua
index 2e3c6b18d753e894e7c907657c21a5962ad02b46..415e531348750c493adaaa761c8d2d29a589eed2 100644 (file)
@@ -25,6 +25,20 @@ local rostermanager = require "core.rostermanager";
 local sessionmanager = require "core.sessionmanager";\r
 local offlinemanager = require "core.offlinemanager";\r
 \r
+local _core_route_stanza = core_route_stanza;\r
+local core_route_stanza;\r
+function core_route_stanza(origin, stanza)\r
+       if stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" and stanza.attr.type ~= "error" then\r
+               local node, host = jid_split(stanza.attr.to);\r
+               host = hosts[host];\r
+               if host and host.type == "local" then\r
+                       handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza);\r
+                       return;\r
+               end\r
+       end\r
+       _core_route_stanza(origin, stanza);\r
+end\r
+\r
 function handle_presence(origin, stanza, from_bare, to_bare, core_route_stanza, inbound)\r
        local type = stanza.attr.type;\r
        if type and type ~= "unavailable" and type ~= "error" then\r
@@ -51,7 +65,7 @@ function handle_normal_presence(origin, stanza, core_route_stanza)
                end\r
                local node, host = jid_split(stanza.attr.from);\r
                for _, res in pairs(hosts[host].sessions[node].sessions) do -- broadcast to all resources\r
-                       if res ~= origin and res.full_jid then -- to resource. FIXME is res.full_jid the correct check? Maybe it should be res.presence\r
+                       if res ~= origin and res.presence then -- to resource\r
                                stanza.attr.to = res.full_jid;\r
                                core_route_stanza(origin, stanza);\r
                        end\r
@@ -254,6 +268,7 @@ local function presence_handler(data)
                        core_route_stanza(origin, stanza);\r
                end\r
        end\r
+       return true;\r
 end\r
 \r
 local add_handler = require "core.eventmanager2".add_handler;\r