Comparison

plugins/mod_presence.lua @ 2525:e385511b3a54

mod_presence: Respond with an unavailable presence when subscribers probe and no resources are available.
author Waqas Hussain <waqas20@gmail.com>
date Fri, 29 Jan 2010 18:16:39 +0500
parent 2461:a6a50cf0e444
child 2531:697ff4f98033
comparison
equal deleted inserted replaced
2524:b427f5401ce7 2525:e385511b3a54
215 end 215 end
216 216
217 if stanza.attr.type == "probe" then 217 if stanza.attr.type == "probe" then
218 if rostermanager.is_contact_subscribed(node, host, from_bare) then 218 if rostermanager.is_contact_subscribed(node, host, from_bare) then
219 if 0 == send_presence_of_available_resources(node, host, st_from, origin, core_route_stanza) then 219 if 0 == send_presence_of_available_resources(node, host, st_from, origin, core_route_stanza) then
220 -- TODO send last recieved unavailable presence (or we MAY do nothing, which is fine too) 220 core_route_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unavailable"})); -- TODO send last activity
221 end 221 end
222 else 222 else
223 core_route_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unsubscribed"})); 223 core_route_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unsubscribed"}));
224 end 224 end
225 elseif stanza.attr.type == "subscribe" then 225 elseif stanza.attr.type == "subscribe" then
226 if rostermanager.is_contact_subscribed(node, host, from_bare) then 226 if rostermanager.is_contact_subscribed(node, host, from_bare) then
227 core_route_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="subscribed"})); -- already subscribed 227 core_route_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="subscribed"})); -- already subscribed
228 -- Sending presence is not clearly stated in the RFC, but it seems appropriate 228 -- 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, core_route_stanza) then 229 if 0 == send_presence_of_available_resources(node, host, from_bare, origin, core_route_stanza) then
230 -- TODO send last recieved unavailable presence (or we MAY do nothing, which is fine too) 230 core_route_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unavailable"})); -- TODO send last activity
231 end 231 end
232 else 232 else
233 core_route_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unavailable"})); -- acknowledging receipt 233 core_route_stanza(hosts[host], st.presence({from=to_bare, to=from_bare, type="unavailable"})); -- acknowledging receipt
234 if not rostermanager.is_contact_pending_in(node, host, from_bare) then 234 if not rostermanager.is_contact_pending_in(node, host, from_bare) then
235 if rostermanager.set_contact_pending_in(node, host, from_bare) then 235 if rostermanager.set_contact_pending_in(node, host, from_bare) then