Software /
code /
prosody
Comparison
plugins/mod_presence.lua @ 7331:c8ad387aab1c
mod_presence, mod_roster: Move responsibility for sending presence on roster removal to mod_presence
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 04 Apr 2016 17:15:10 +0200 |
parent | 7281:21da137d83b0 |
child | 7332:ba32289e8d0b |
comparison
equal
deleted
inserted
replaced
7329:ab811c1bb730 | 7331:c8ad387aab1c |
---|---|
355 core_post_stanza(session, pres, true); | 355 core_post_stanza(session, pres, true); |
356 end | 356 end |
357 session.directed = nil; | 357 session.directed = nil; |
358 end | 358 end |
359 end); | 359 end); |
360 | |
361 module:hook("roster-item-removed", function (event) | |
362 local username = event.username; | |
363 local session = event.origin; | |
364 local roster = event.roster or session and session.roster; | |
365 local jid = event.jid; | |
366 local item = event.item; | |
367 | |
368 local subscription = item and item.subscription or "none"; | |
369 local ask = item and item.ask; | |
370 local pending = roster and roster[false].pending[jid]; | |
371 | |
372 if subscription == "both" or subscription == "from" or pending then | |
373 core_post_stanza(session, st.presence({type="unsubscribed", from=session.full_jid, to=jid})); | |
374 end | |
375 | |
376 if subscription == "both" or subscription == "to" or ask then | |
377 core_post_stanza(session, st.presence({type="unsubscribe", from=session.full_jid, to=jid})); | |
378 end | |
379 | |
380 end, -1); | |
381 |