# HG changeset patch # User Waqas Hussain # Date 1264781211 -18000 # Node ID 621f71d7ba2b4f3e083fb5a05fb86cd567db8cd4 # Parent 298d0ed3f40df024f135ecd6323c798de58b3082 mod_presence: Added handler for presence subscriptions and probes to local hosts. diff -r 298d0ed3f40d -r 621f71d7ba2b plugins/mod_presence.lua --- a/plugins/mod_presence.lua Fri Jan 29 21:04:36 2010 +0500 +++ b/plugins/mod_presence.lua Fri Jan 29 21:06:51 2010 +0500 @@ -309,13 +309,6 @@ end return true; end); -module:hook("presence/host", function (data) - local stanza = data.stanza; - local reply = st.reply(stanza); - reply.attr.type = "unsubscribed"; - handle_inbound_presence_subscriptions_and_probes(data.origin, reply, jid_bare(stanza.attr.to), jid_bare(stanza.attr.from), core_route_stanza); - return true; -end); module:hook("presence/full", function(data) -- inbound presence to full JID recieved local origin, stanza = data.origin, data.stanza; @@ -333,6 +326,20 @@ end -- resource not online, discard return true; end); +module:hook("presence/host", function(data) + -- inbound presence to the host + local origin, stanza = data.origin, data.stanza; + + local from_bare = jid_bare(stanza.attr.from); + local t = stanza.attr.type; + if t == "probe" then + core_route_stanza(hosts[module.host], st.presence({ from = module.host, to = from_bare, id = stanza.attr.id })); + elseif t == "subscribe" then + core_route_stanza(hosts[module.host], st.presence({ from = module.host, to = from_bare, id = stanza.attr.id, type = "subscribed" })); + core_route_stanza(hosts[module.host], st.presence({ from = module.host, to = from_bare, id = stanza.attr.id })); + end + return true; +end); module:hook("resource-unbind", function(event) local session, err = event.session, event.error;