Comparison

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
comparison
equal deleted inserted replaced
10513:7a82f7ecf0ce 10514:f0e9e5bda415
179 -- 2. roster_push () 179 -- 2. roster_push ()
180 -- 3. send_presence_of_available_resources 180 -- 3. send_presence_of_available_resources
181 if rostermanager.subscribed(node, host, to_bare) then 181 if rostermanager.subscribed(node, host, to_bare) then
182 rostermanager.roster_push(node, host, to_bare); 182 rostermanager.roster_push(node, host, to_bare);
183 end 183 end
184 core_post_stanza(origin, stanza); 184 if rostermanager.is_contact_subscribed(node, host, to_bare) then
185 send_presence_of_available_resources(node, host, to_bare, origin); 185 core_post_stanza(origin, stanza);
186 send_presence_of_available_resources(node, host, to_bare, origin);
187 end
186 if rostermanager.is_user_subscribed(node, host, to_bare) then 188 if rostermanager.is_user_subscribed(node, host, to_bare) then
187 core_post_stanza(origin, st.presence({ type = "probe", from = from_bare, to = to_bare })); 189 core_post_stanza(origin, st.presence({ type = "probe", from = from_bare, to = to_bare }));
188 end 190 end
189 elseif stanza.attr.type == "unsubscribed" then 191 elseif stanza.attr.type == "unsubscribed" then
190 -- 1. send unavailable 192 -- 1. send unavailable
227 core_post_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="subscribed"}), true); -- already subscribed 229 core_post_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="subscribed"}), true); -- already subscribed
228 -- Sending presence is not clearly stated in the RFC, but it seems appropriate 230 -- Sending presence is not clearly stated in the RFC, but it seems appropriate
229 if 0 == send_presence_of_available_resources(node, host, from_bare, origin) then 231 if 0 == send_presence_of_available_resources(node, host, from_bare, origin) then
230 core_post_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unavailable"}), true); -- TODO send last activity 232 core_post_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unavailable"}), true); -- TODO send last activity
231 end 233 end
234 elseif rostermanager.is_contact_preapproved(node, host, from_bare) then
235 if not rostermanager.is_contact_pending_in(node, host, from_bare) then
236 if rostermanager.set_contact_pending_in(node, host, from_bare, stanza) then
237 core_post_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="subscribed"}), true);
238 end -- TODO else return error, unable to save
239 end
232 else 240 else
233 core_post_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unavailable"}), true); -- acknowledging receipt 241 core_post_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unavailable"}), true); -- acknowledging receipt
234 if not rostermanager.is_contact_pending_in(node, host, from_bare) then 242 if not rostermanager.is_contact_pending_in(node, host, from_bare) then
235 if rostermanager.set_contact_pending_in(node, host, from_bare, stanza) then 243 if rostermanager.set_contact_pending_in(node, host, from_bare, stanza) then
236 sessionmanager.send_to_available_resources(node, host, stanza); 244 sessionmanager.send_to_available_resources(node, host, stanza);