Changeset

7779:b1f80447a2b1

Merge 0.9->0.10
author Kim Alvefur <zash@zash.se>
date Fri, 09 Dec 2016 17:07:57 +0100
parents 7776:63f50a84318f (current diff) 7778:62e7d6a73c72 (diff)
children 7780:dbd202e7c587 7781:0d31d8052dd8
files core/rostermanager.lua plugins/mod_presence.lua util/dependencies.lua
diffstat 2 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/core/rostermanager.lua	Thu Dec 08 17:51:23 2016 +0100
+++ b/core/rostermanager.lua	Fri Dec 09 17:07:57 2016 +0100
@@ -234,6 +234,18 @@
 	local item = roster[jid];
 	return item and (item.subscription == "from" or item.subscription == "both"), err;
 end
+local 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);
@@ -350,6 +362,7 @@
 	process_inbound_subscription_cancellation = process_inbound_subscription_cancellation;
 	process_inbound_unsubscribe = process_inbound_unsubscribe;
 	is_contact_subscribed = is_contact_subscribed;
+	is_user_subscribed = is_user_subscribed;
 	is_contact_pending_in = is_contact_pending_in;
 	set_contact_pending_in = set_contact_pending_in;
 	is_contact_pending_out = is_contact_pending_out;
--- a/plugins/mod_presence.lua	Thu Dec 08 17:51:23 2016 +0100
+++ b/plugins/mod_presence.lua	Fri Dec 09 17:07:57 2016 +0100
@@ -178,7 +178,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