Software /
code /
prosody
Changeset
7805:1cb90024e8db
Merge
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 10 Dec 2016 03:00:50 +0100 |
parents | 7778:62e7d6a73c72 (diff) 7804:4e649ffdb314 (current diff) |
children | 7806:00bca79ae778 |
files | |
diffstat | 2 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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);
--- 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