Software / code / prosody
Comparison
plugins/muc/muc.lib.lua @ 7669:b332db1baf0b
MUC: Remove "server changed your nickname" status code, it gets into the wrong places
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 01 Oct 2016 23:20:58 +0200 |
| parent | 7668:96c6c25a51e1 |
| child | 7686:8d6f367bed8c |
comparison
equal
deleted
inserted
replaced
| 7668:96c6c25a51e1 | 7669:b332db1baf0b |
|---|---|
| 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.nick; | |
| 495 if orig_occupant == nil then | 494 if orig_occupant == nil then |
| 496 event_name = "muc-occupant-pre-join"; | 495 event_name = "muc-occupant-pre-join"; |
| 497 event.occupant = dest_occupant; | 496 event.occupant = dest_occupant; |
| 498 elseif dest_occupant == nil then | 497 elseif dest_occupant == nil then |
| 499 event_name = "muc-occupant-pre-leave"; | 498 event_name = "muc-occupant-pre-leave"; |
| 502 event_name = "muc-occupant-pre-change"; | 501 event_name = "muc-occupant-pre-change"; |
| 503 event.orig_occupant = orig_occupant; | 502 event.orig_occupant = orig_occupant; |
| 504 event.dest_occupant = dest_occupant; | 503 event.dest_occupant = dest_occupant; |
| 505 end | 504 end |
| 506 if module:fire_event(event_name, event) then return true; end | 505 if module:fire_event(event_name, event) then return true; end |
| 507 local nick_overridden = orig_nick and orig_nick ~= dest_occupant.nick; | |
| 508 | 506 |
| 509 -- Check for nick conflicts | 507 -- 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 | 508 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); | 509 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(); | 510 local reply = st.error_reply(stanza, "cancel", "conflict"):up(); |
| 575 if dest_occupant ~= nil then | 573 if dest_occupant ~= nil then |
| 576 dest_occupant:set_session(real_jid, stanza); | 574 dest_occupant:set_session(real_jid, stanza); |
| 577 local dest_x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user";}); | 575 local dest_x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user";}); |
| 578 if orig_occupant == nil and self:get_whois() == "anyone" then | 576 if orig_occupant == nil and self:get_whois() == "anyone" then |
| 579 dest_x:tag("status", {code = "100"}):up(); | 577 dest_x:tag("status", {code = "100"}):up(); |
| 580 end | |
| 581 if nick_overridden then | |
| 582 dest_x:tag("status", {code = "210"}):up(); | |
| 583 end | 578 end |
| 584 self:save_occupant(dest_occupant); | 579 self:save_occupant(dest_occupant); |
| 585 | 580 |
| 586 if orig_occupant == nil or muc_x then | 581 if orig_occupant == nil or muc_x then |
| 587 -- Send occupant list to newly joined user | 582 -- Send occupant list to newly joined user |