X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=plugins%2Fmod_presence.lua;h=415e531348750c493adaaa761c8d2d29a589eed2;hb=922473aea8fbf35a054fb00dbe7c01e07854dad3;hp=2e3c6b18d753e894e7c907657c21a5962ad02b46;hpb=5d6afacc4f8552448a60efbf54782d1a4976ca81;p=prosody.git diff --git a/plugins/mod_presence.lua b/plugins/mod_presence.lua index 2e3c6b18..415e5313 100644 --- a/plugins/mod_presence.lua +++ b/plugins/mod_presence.lua @@ -25,6 +25,20 @@ local rostermanager = require "core.rostermanager"; local sessionmanager = require "core.sessionmanager"; local offlinemanager = require "core.offlinemanager"; +local _core_route_stanza = core_route_stanza; +local core_route_stanza; +function core_route_stanza(origin, stanza) + if stanza.attr.type ~= nil and stanza.attr.type ~= "unavailable" and stanza.attr.type ~= "error" then + local node, host = jid_split(stanza.attr.to); + host = hosts[host]; + if host and host.type == "local" then + handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to), core_route_stanza); + return; + end + end + _core_route_stanza(origin, stanza); +end + function handle_presence(origin, stanza, from_bare, to_bare, core_route_stanza, inbound) local type = stanza.attr.type; if type and type ~= "unavailable" and type ~= "error" then @@ -51,7 +65,7 @@ function handle_normal_presence(origin, stanza, core_route_stanza) end local node, host = jid_split(stanza.attr.from); for _, res in pairs(hosts[host].sessions[node].sessions) do -- broadcast to all resources - if res ~= origin and res.full_jid then -- to resource. FIXME is res.full_jid the correct check? Maybe it should be res.presence + if res ~= origin and res.presence then -- to resource stanza.attr.to = res.full_jid; core_route_stanza(origin, stanza); end @@ -254,6 +268,7 @@ local function presence_handler(data) core_route_stanza(origin, stanza); end end + return true; end local add_handler = require "core.eventmanager2".add_handler;