# HG changeset patch # User Kim Alvefur # Date 1481335250 -3600 # Node ID 1cb90024e8db6001f64ebe9b58aa126f2f5e1b82 # Parent 62e7d6a73c721aacdb9f7bf3aecc764e094e3c68# Parent 4e649ffdb314cf9bbb155fa93d7ba458d2b15b17 Merge diff -r 4e649ffdb314 -r 1cb90024e8db core/rostermanager.lua --- a/core/rostermanager.lua Mon Dec 05 12:53:50 2016 +0000 +++ b/core/rostermanager.lua Sat Dec 10 03:00:50 2016 +0100 @@ -210,6 +210,18 @@ local item = roster[jid]; return item and (item.subscription == "from" or item.subscription == "both"), err; end +function is_user_subscribed(username, host, jid) + do + local selfjid = username.."@"..host; + local user_subscription = _get_online_roster_subscription(selfjid, jid); + if user_subscription then return (user_subscription == "both" or user_subscription == "to"); end + local contact_subscription = _get_online_roster_subscription(jid, selfjid); + if contact_subscription then return (contact_subscription == "both" or contact_subscription == "from"); end + end + local roster, err = load_roster(username, host); + local item = roster[jid]; + return item and (item.subscription == "to" or item.subscription == "both"), err; +end function is_contact_pending_in(username, host, jid) local roster = load_roster(username, host); diff -r 4e649ffdb314 -r 1cb90024e8db plugins/mod_presence.lua --- a/plugins/mod_presence.lua Mon Dec 05 12:53:50 2016 +0000 +++ b/plugins/mod_presence.lua Sat Dec 10 03:00:50 2016 +0100 @@ -201,7 +201,9 @@ end core_post_stanza(origin, stanza); send_presence_of_available_resources(node, host, to_bare, origin); - core_post_stanza(origin, st.presence({ type = "probe", from = from_bare, to = to_bare })); + if rostermanager.is_user_subscribed(node, host, to_bare) then + core_post_stanza(origin, st.presence({ type = "probe", from = from_bare, to = to_bare })); + end elseif stanza.attr.type == "unsubscribed" then -- 1. send unavailable -- 2. route stanza