aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2019-12-19 10:03:16 +0000
committerMatthew Wild <mwild1@gmail.com>2019-12-19 10:03:16 +0000
commit173990157fad6d4507e8ce2dc214e7bf35a17822 (patch)
tree1d7cba4384d9413b605b7e06c729b3fb44dfa1fa /plugins
parentad26a3b047ab0ae2efa0d61553e32f77da2ccac4 (diff)
downloadprosody-173990157fad6d4507e8ce2dc214e7bf35a17822.tar.gz
prosody-173990157fad6d4507e8ce2dc214e7bf35a17822.zip
rostermanager, mod_presence: Support for subscription preapproval (fixes #686)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_presence.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/plugins/mod_presence.lua b/plugins/mod_presence.lua
index f7f458ca..b874277c 100644
--- a/plugins/mod_presence.lua
+++ b/plugins/mod_presence.lua
@@ -181,8 +181,10 @@ function handle_outbound_presence_subscriptions_and_probes(origin, stanza, from_
if rostermanager.subscribed(node, host, to_bare) then
rostermanager.roster_push(node, host, to_bare);
end
- core_post_stanza(origin, stanza);
- send_presence_of_available_resources(node, host, to_bare, origin);
+ if rostermanager.is_contact_subscribed(node, host, to_bare) then
+ core_post_stanza(origin, stanza);
+ send_presence_of_available_resources(node, host, to_bare, origin);
+ end
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
@@ -229,6 +231,12 @@ function handle_inbound_presence_subscriptions_and_probes(origin, stanza, from_b
if 0 == send_presence_of_available_resources(node, host, from_bare, origin) then
core_post_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unavailable"}), true); -- TODO send last activity
end
+ elseif rostermanager.is_contact_preapproved(node, host, from_bare) then
+ if not rostermanager.is_contact_pending_in(node, host, from_bare) then
+ if rostermanager.set_contact_pending_in(node, host, from_bare, stanza) then
+ core_post_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="subscribed"}), true);
+ end -- TODO else return error, unable to save
+ end
else
core_post_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unavailable"}), true); -- acknowledging receipt
if not rostermanager.is_contact_pending_in(node, host, from_bare) then