Comparison

plugins/muc/muc.lib.lua @ 7668:96c6c25a51e1

MUC: Fix logic of nickname override detection (thanks mimi89999)
author Kim Alvefur <zash@zash.se>
date Sat, 01 Oct 2016 22:11:34 +0200
parent 7667:5523880760b3
child 7669:b332db1baf0b
comparison
equal deleted inserted replaced
7667:5523880760b3 7668:96c6c25a51e1
489 origin = origin; 489 origin = origin;
490 stanza = stanza; 490 stanza = stanza;
491 is_first_session = is_first_dest_session; 491 is_first_session = is_first_dest_session;
492 is_last_session = is_last_orig_session; 492 is_last_session = is_last_orig_session;
493 }; 493 };
494 local orig_nick = dest_occupant and dest_occupant.jid; 494 local orig_nick = dest_occupant and dest_occupant.nick;
495 if orig_occupant == nil then 495 if orig_occupant == nil then
496 event_name = "muc-occupant-pre-join"; 496 event_name = "muc-occupant-pre-join";
497 event.occupant = dest_occupant; 497 event.occupant = dest_occupant;
498 elseif dest_occupant == nil then 498 elseif dest_occupant == nil then
499 event_name = "muc-occupant-pre-leave"; 499 event_name = "muc-occupant-pre-leave";
502 event_name = "muc-occupant-pre-change"; 502 event_name = "muc-occupant-pre-change";
503 event.orig_occupant = orig_occupant; 503 event.orig_occupant = orig_occupant;
504 event.dest_occupant = dest_occupant; 504 event.dest_occupant = dest_occupant;
505 end 505 end
506 if module:fire_event(event_name, event) then return true; end 506 if module:fire_event(event_name, event) then return true; end
507 local nick_overridden = dest_occupant and orig_nick ~= dest_occupant.nick; 507 local nick_overridden = orig_nick and orig_nick ~= dest_occupant.nick;
508 508
509 -- Check for nick conflicts 509 -- Check for nick conflicts
510 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 510 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
511 log("debug", "%s couldn't join due to nick conflict: %s", real_jid, dest_occupant.nick); 511 log("debug", "%s couldn't join due to nick conflict: %s", real_jid, dest_occupant.nick);
512 local reply = st.error_reply(stanza, "cancel", "conflict"):up(); 512 local reply = st.error_reply(stanza, "cancel", "conflict"):up();