Mercurial > prosody-hg
comparison plugins/mod_presence.lua @ 7344:81efa212db1e
mod_presence: Construct a 'from' JID when roster items are removed outside of a session
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Fri, 08 Apr 2016 16:35:23 +0200 |
| parents | ba32289e8d0b |
| children | 0c69305ab525 |
comparison
equal
deleted
inserted
replaced
| 7342:79a5db780e8b | 7344:81efa212db1e |
|---|---|
| 362 local username = event.username; | 362 local username = event.username; |
| 363 local session = event.origin; | 363 local session = event.origin; |
| 364 local roster = event.roster or session and session.roster; | 364 local roster = event.roster or session and session.roster; |
| 365 local jid = event.jid; | 365 local jid = event.jid; |
| 366 local item = event.item; | 366 local item = event.item; |
| 367 local from_jid = origin.full_jid or (username .. "@" .. module.host); | |
| 367 | 368 |
| 368 local subscription = item and item.subscription or "none"; | 369 local subscription = item and item.subscription or "none"; |
| 369 local ask = item and item.ask; | 370 local ask = item and item.ask; |
| 370 local pending = roster and roster[false].pending[jid]; | 371 local pending = roster and roster[false].pending[jid]; |
| 371 | 372 |
| 372 if subscription == "both" or subscription == "from" or pending then | 373 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 core_post_stanza(session, st.presence({type="unsubscribed", from=from_jid, to=jid})); |
| 374 end | 375 end |
| 375 | 376 |
| 376 if subscription == "both" or subscription == "to" or ask then | 377 if subscription == "both" or subscription == "to" or ask then |
| 377 send_presence_of_available_resources(username, module.host, jid, session, st.presence({type="unavailable"})); | 378 send_presence_of_available_resources(username, module.host, jid, session, st.presence({type="unavailable"})); |
| 378 core_post_stanza(session, st.presence({type="unsubscribe", from=session.full_jid, to=jid})); | 379 core_post_stanza(session, st.presence({type="unsubscribe", from=from_jid, to=jid})); |
| 379 end | 380 end |
| 380 | 381 |
| 381 end, -1); | 382 end, -1); |
| 382 | 383 |
