# HG changeset patch # User Waqas Hussain # Date 1256133662 -18000 # Node ID 4ab83f96585a43d5eeac5a97dfcbdd4f47a77202 # Parent a919511c45ac662d26e834e9d45915e628511636 mod_presence: Send unavailable presence when sending unsubscribed presence stanzas (some legacy clients continue to display unsubscribed contacts as available). diff -r a919511c45ac -r 4ab83f96585a plugins/mod_presence.lua --- a/plugins/mod_presence.lua Wed Oct 21 14:05:33 2009 +0100 +++ b/plugins/mod_presence.lua Wed Oct 21 19:01:02 2009 +0500 @@ -142,7 +142,7 @@ stanza.attr.to = nil; -- reset it end -function send_presence_of_available_resources(user, host, jid, recipient_session, core_route_stanza) +function send_presence_of_available_resources(user, host, jid, recipient_session, core_route_stanza, stanza) local h = hosts[host]; local count = 0; if h and h.type == "local" then @@ -151,6 +151,7 @@ for k, session in pairs(u.sessions) do local pres = session.presence; if pres then + if stanza then pres = stanza; pres.attr.from = session.full_jid; end pres.attr.to = jid; core_route_stanza(session, pres); pres.attr.to = nil; @@ -199,6 +200,9 @@ rostermanager.roster_push(node, host, to_bare); end core_route_stanza(origin, stanza); + -- COMPAT: Some legacy clients keep displaying unsubscribed contacts as online unless an unavailable presence is sent: + send_presence_of_available_resources(node, host, to_bare, origin, core_route_stanza, + st.presence({ type="unavailable", from=from_bare, to=to_bare, id=stanza.attr.id })); end stanza.attr.from, stanza.attr.to = st_from, st_to; end