# HG changeset patch # User Matthew Wild # Date 1536944772 -3600 # Node ID a47bba3b35f34646407fcbe87704e52cb5b972e3 # Parent c9eef7e8ee65ab3550b720cb7c34b4bda95d07ae MUC: Don't kick user of a reserved nick if it's theirs (thanks pep.) diff -r c9eef7e8ee65 -r a47bba3b35f3 plugins/muc/muc.lib.lua --- a/plugins/muc/muc.lib.lua Wed May 16 23:57:09 2018 +0200 +++ b/plugins/muc/muc.lib.lua Fri Sep 14 18:06:12 2018 +0100 @@ -930,9 +930,12 @@ local registration_data; if item.attr.nick then local room_nick = self.jid.."/"..item.attr.nick; - if self:get_occupant_by_nick(room_nick) then + local existing_occupant = self:get_occupant_by_nick(room_nick); + if existing_occupant and existing_occupant.bare_jid ~= item.attr.jid then + module:log("debug", "Existing occupant for %s: %s does not match %s", room_nick, existing_occupant.bare_jid, item.attr.jid); self:set_role(true, room_nick, nil, "This nickname is reserved"); end + module:log("debug", "Reserving %s for %s (%s)", item.attr.nick, item.attr.jid, item.attr.affiliation); registration_data = { reserved_nickname = item.attr.nick }; end success, errtype, err = self:set_affiliation(actor, item.attr.jid, item.attr.affiliation, reason, registration_data); diff -r c9eef7e8ee65 -r a47bba3b35f3 spec/scansion/muc_register.scs --- a/spec/scansion/muc_register.scs Wed May 16 23:57:09 2018 +0200 +++ b/spec/scansion/muc_register.scs Fri Sep 14 18:06:12 2018 +0100 @@ -381,3 +381,65 @@ +Juliet sends: + + +Juliet receives: + + +Romeo receives: + + +# Rosaline joins as herself + +Rosaline sends: + + + + +Rosaline receives: + + +Rosaline receives: + + +Rosaline receives: + + +Romeo receives: + + + + + + +# Romeo reserves her nickname for her + +Romeo sends: + + + + + + +Romeo receives: + + + + + + + + +Romeo receives: + + +Rosaline receives: + + + + + + + +