comparison plugins/mod_presence.lua @ 7348:a8ca12e7c2fb

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Fri, 08 Apr 2016 17:54:50 +0200
parents 0c69305ab525
children 7eec6f3c7300
comparison
equal deleted inserted replaced
7347:795a95258292 7348:a8ca12e7c2fb
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 = session.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