# HG changeset patch # User Waqas Hussain # Date 1264781733 -18000 # Node ID d6ca46b834d91ea2824a5e2604cec3be89b3c107 # Parent b1b1b4a7db264d275400b8a15a3ac73db78d9453# Parent 7968e8b3ecf94fa5880fc8f340d497a46ff1a7eb Merge with trunk. diff -r 7968e8b3ecf9 -r d6ca46b834d9 core/stanza_router.lua --- a/core/stanza_router.lua Fri Jan 29 15:13:06 2010 +0000 +++ b/core/stanza_router.lua Fri Jan 29 21:15:33 2010 +0500 @@ -98,7 +98,7 @@ return; -- FIXME what should we do here? does this work with subdomains? end end - core_post_stanza(origin, stanza); + core_post_stanza(origin, stanza, origin.full_jid); else local h = hosts[stanza.attr.to or origin.host or origin.to_host]; if h then @@ -119,7 +119,7 @@ end end -function core_post_stanza(origin, stanza) +function core_post_stanza(origin, stanza, preevents) local to = stanza.attr.to; local node, host, resource = jid_split(to); local to_bare = node and (node.."@"..host) or host; -- bare JID @@ -143,7 +143,7 @@ end local event_data = {origin=origin, stanza=stanza}; - if origin.full_jid == stanza.attr.from then -- c2s connection + if preevents then -- c2s connection if hosts[origin.host].events.fire_event('pre-'..stanza.name..to_type, event_data) then return; end -- do preprocessing end local h = hosts[to_bare] or hosts[host or origin.host]; diff -r 7968e8b3ecf9 -r d6ca46b834d9 plugins/mod_presence.lua --- a/plugins/mod_presence.lua Fri Jan 29 15:13:06 2010 +0000 +++ b/plugins/mod_presence.lua Fri Jan 29 21:15:33 2010 +0500 @@ -76,6 +76,7 @@ end end if stanza.attr.type == nil and not origin.presence then -- initial presence + origin.presence = stanza; -- FIXME repeated later local probe = st.presence({from = origin.full_jid, type = "probe"}); for jid, item in pairs(roster) do -- probe all contacts we are subscribed to if item.subscription == "both" or item.subscription == "to" then @@ -309,13 +310,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 +327,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;