Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 6431:540f4e33394a
muc: Add 'occupant' to muc-occupant-{joined,left,session-new} events (thanks daurnimator/fippo)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 26 Sep 2014 17:34:15 +0100 |
parent | 6429:675aea867574 |
child | 6451:385932a83013 |
comparison
equal
deleted
inserted
replaced
6430:ceaf2a0d05eb | 6431:540f4e33394a |
---|---|
396 is_last_session = is_last_orig_session; | 396 is_last_session = is_last_orig_session; |
397 }; | 397 }; |
398 if orig_occupant == nil then | 398 if orig_occupant == nil then |
399 event_name = "muc-occupant-pre-join"; | 399 event_name = "muc-occupant-pre-join"; |
400 event.is_new_room = is_new_room; | 400 event.is_new_room = is_new_room; |
401 event.occupant = dest_occupant; | |
401 elseif dest_occupant == nil then | 402 elseif dest_occupant == nil then |
402 event_name = "muc-occupant-pre-leave"; | 403 event_name = "muc-occupant-pre-leave"; |
404 event.occupant = orig_occupant; | |
403 else | 405 else |
404 event_name = "muc-occupant-pre-change"; | 406 event_name = "muc-occupant-pre-change"; |
407 event.orig_occupant = orig_occupant; | |
408 event.dest_occupant = dest_occupant; | |
405 end | 409 end |
406 if module:fire_event(event_name, event) then return true; end | 410 if module:fire_event(event_name, event) then return true; end |
407 | 411 |
408 -- Check for nick conflicts | 412 -- Check for nick conflicts |
409 if dest_occupant ~= nil and not is_first_dest_session and bare_jid ~= jid_bare(dest_occupant.bare_jid) then -- new nick or has different bare real jid | 413 if dest_occupant ~= nil and not is_first_dest_session and bare_jid ~= jid_bare(dest_occupant.bare_jid) then -- new nick or has different bare real jid |
458 end | 462 end |
459 self:save_occupant(orig_occupant); | 463 self:save_occupant(orig_occupant); |
460 self:publicise_occupant_status(orig_occupant, orig_x, dest_nick); | 464 self:publicise_occupant_status(orig_occupant, orig_x, dest_nick); |
461 | 465 |
462 if is_last_orig_session then | 466 if is_last_orig_session then |
463 module:fire_event("muc-occupant-left", {room = self; nick = orig_occupant.nick;}); | 467 module:fire_event("muc-occupant-left", {room = self; nick = orig_occupant.nick; occupant = orig_occupant;}); |
464 end | 468 end |
465 end | 469 end |
466 | 470 |
467 if dest_occupant ~= nil then | 471 if dest_occupant ~= nil then |
468 dest_occupant:set_session(real_jid, stanza); | 472 dest_occupant:set_session(real_jid, stanza); |
496 self:route_stanza(pr); | 500 self:route_stanza(pr); |
497 end | 501 end |
498 | 502 |
499 if orig_occupant == nil then | 503 if orig_occupant == nil then |
500 if is_first_dest_session then | 504 if is_first_dest_session then |
501 module:fire_event("muc-occupant-joined", {room = self; nick = dest_occupant.nick; stanza = stanza;}); | 505 module:fire_event("muc-occupant-joined", {room = self; nick = dest_occupant.nick; occupant = dest_occupant;}); |
502 end | 506 end |
503 module:fire_event("muc-occupant-session-new", {room = self; nick = dest_occupant.nick; stanza = stanza; jid = real_jid;}); | 507 module:fire_event("muc-occupant-session-new", {room = self; nick = dest_occupant.nick; occupant = dest_occupant; stanza = stanza; jid = real_jid;}); |
504 end | 508 end |
505 end | 509 end |
506 elseif type ~= 'result' then -- bad type | 510 elseif type ~= 'result' then -- bad type |
507 if type ~= 'visible' and type ~= 'invisible' then -- COMPAT ejabberd can broadcast or forward XEP-0018 presences | 511 if type ~= 'visible' and type ~= 'invisible' then -- COMPAT ejabberd can broadcast or forward XEP-0018 presences |
508 origin.send(st.error_reply(stanza, "modify", "bad-request")); -- FIXME correct error? | 512 origin.send(st.error_reply(stanza, "modify", "bad-request")); -- FIXME correct error? |
667 self:save_occupant(occupant); | 671 self:save_occupant(occupant); |
668 occupants_updated[occupant] = true; | 672 occupants_updated[occupant] = true; |
669 end | 673 end |
670 for occupant in pairs(occupants_updated) do | 674 for occupant in pairs(occupants_updated) do |
671 self:publicise_occupant_status(occupant, x); | 675 self:publicise_occupant_status(occupant, x); |
672 module:fire_event("muc-occupant-left", { room = self; nick = occupant.nick; }); | 676 module:fire_event("muc-occupant-left", { room = self; nick = occupant.nick; occupant = occupant;}); |
673 end | 677 end |
674 end | 678 end |
675 | 679 |
676 function room_mt:destroy(newjid, reason, password) | 680 function room_mt:destroy(newjid, reason, password) |
677 local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"}) | 681 local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"}) |