From fdb852fbbbb9e5da8e72a380e061f662d10f11c7 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 14 Sep 2018 18:06:12 +0100 Subject: MUC: Don't kick user of a reserved nick if it's theirs (thanks pep.) --- plugins/muc/muc.lib.lua | 5 +++- spec/scansion/muc_register.scs | 62 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index 341a848d..4d986457 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -930,9 +930,12 @@ function room_mt:handle_admin_query_set_command(origin, stanza) 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 --git a/spec/scansion/muc_register.scs b/spec/scansion/muc_register.scs index af0cdc07..a97a10df 100644 --- a/spec/scansion/muc_register.scs +++ b/spec/scansion/muc_register.scs @@ -381,3 +381,65 @@ Romeo receives: +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: + + + + + + + + -- cgit v1.2.3