Software /
code /
prosody
Diff
plugins/mod_presence.lua @ 7335:ab7e7d4fe9c1
Merge 0.10->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 05 Apr 2016 12:48:36 +0200 |
parent | 7332:ba32289e8d0b |
child | 7344:81efa212db1e |
line wrap: on
line diff
--- a/plugins/mod_presence.lua Sun Apr 03 15:53:00 2016 +0200 +++ b/plugins/mod_presence.lua Tue Apr 05 12:48:36 2016 +0200 @@ -357,3 +357,26 @@ session.directed = nil; end end); + +module:hook("roster-item-removed", function (event) + local username = event.username; + local session = event.origin; + local roster = event.roster or session and session.roster; + local jid = event.jid; + local item = event.item; + + local subscription = item and item.subscription or "none"; + local ask = item and item.ask; + local pending = roster and roster[false].pending[jid]; + + if subscription == "both" or subscription == "from" or pending then + core_post_stanza(session, st.presence({type="unsubscribed", from=session.full_jid, to=jid})); + end + + if subscription == "both" or subscription == "to" or ask then + send_presence_of_available_resources(username, module.host, jid, session, st.presence({type="unavailable"})); + core_post_stanza(session, st.presence({type="unsubscribe", from=session.full_jid, to=jid})); + end + +end, -1); +