diff options
author | Matthew Wild <mwild1@gmail.com> | 2019-12-19 10:03:16 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2019-12-19 10:03:16 +0000 |
commit | 2de609cb9b976f9b2fb59c4680d86abd1e0ff091 (patch) | |
tree | 1d7cba4384d9413b605b7e06c729b3fb44dfa1fa /plugins | |
parent | 3a14bfec85e586c156b60bdb2907acca3815bed9 (diff) | |
download | prosody-2de609cb9b976f9b2fb59c4680d86abd1e0ff091.tar.gz prosody-2de609cb9b976f9b2fb59c4680d86abd1e0ff091.zip |
rostermanager, mod_presence: Support for subscription preapproval (fixes #686)
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_presence.lua | 12 |
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 |