Software /
code /
prosody
Diff
plugins/mod_presence.lua @ 10514:f0e9e5bda415
rostermanager, mod_presence: Support for subscription preapproval (fixes #686)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 19 Dec 2019 10:03:16 +0000 |
parent | 9790:4a419089ad00 |
child | 10556:79fe4ed1332b |
line wrap: on
line diff
--- a/plugins/mod_presence.lua Tue Dec 17 00:34:39 2019 +0100 +++ b/plugins/mod_presence.lua Thu Dec 19 10:03:16 2019 +0000 @@ -181,8 +181,10 @@ 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 @@ 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