aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-12-09 17:07:57 +0100
committerKim Alvefur <zash@zash.se>2016-12-09 17:07:57 +0100
commitbbaaaa99a4da333262792a211c46ec93ae0b270a (patch)
treeff719b97c8a64a18aa5c5ecd81350e8971332707
parentf9869506eda3fd6248487a7033a40ca2a949e783 (diff)
parent1dbe1533ec336146aead43fca58952d06174e67c (diff)
downloadprosody-bbaaaa99a4da333262792a211c46ec93ae0b270a.tar.gz
prosody-bbaaaa99a4da333262792a211c46ec93ae0b270a.zip
Merge 0.9->0.10
-rw-r--r--core/rostermanager.lua13
-rw-r--r--plugins/mod_presence.lua4
2 files changed, 16 insertions, 1 deletions
diff --git a/core/rostermanager.lua b/core/rostermanager.lua
index 58d1f16e..88bd1e66 100644
--- a/core/rostermanager.lua
+++ b/core/rostermanager.lua
@@ -234,6 +234,18 @@ local function is_contact_subscribed(username, host, jid)
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 @@ return {
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;
diff --git a/plugins/mod_presence.lua b/plugins/mod_presence.lua
index e4a317bc..2acc7db2 100644
--- a/plugins/mod_presence.lua
+++ b/plugins/mod_presence.lua
@@ -178,7 +178,9 @@ function handle_outbound_presence_subscriptions_and_probes(origin, stanza, from_
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