Comparison

plugins/muc/muc.lib.lua @ 9315:a47bba3b35f3

MUC: Don't kick user of a reserved nick if it's theirs (thanks pep.)
author Matthew Wild <mwild1@gmail.com>
date Fri, 14 Sep 2018 18:06:12 +0100
parent 9312:6cab07323274
child 9444:7c1cdf5f9f83
comparison
equal deleted inserted replaced
9314:c9eef7e8ee65 9315:a47bba3b35f3
928 local success, errtype, err 928 local success, errtype, err
929 if item.attr.affiliation and item.attr.jid and not item.attr.role then 929 if item.attr.affiliation and item.attr.jid and not item.attr.role then
930 local registration_data; 930 local registration_data;
931 if item.attr.nick then 931 if item.attr.nick then
932 local room_nick = self.jid.."/"..item.attr.nick; 932 local room_nick = self.jid.."/"..item.attr.nick;
933 if self:get_occupant_by_nick(room_nick) then 933 local existing_occupant = self:get_occupant_by_nick(room_nick);
934 if existing_occupant and existing_occupant.bare_jid ~= item.attr.jid then
935 module:log("debug", "Existing occupant for %s: %s does not match %s", room_nick, existing_occupant.bare_jid, item.attr.jid);
934 self:set_role(true, room_nick, nil, "This nickname is reserved"); 936 self:set_role(true, room_nick, nil, "This nickname is reserved");
935 end 937 end
938 module:log("debug", "Reserving %s for %s (%s)", item.attr.nick, item.attr.jid, item.attr.affiliation);
936 registration_data = { reserved_nickname = item.attr.nick }; 939 registration_data = { reserved_nickname = item.attr.nick };
937 end 940 end
938 success, errtype, err = self:set_affiliation(actor, item.attr.jid, item.attr.affiliation, reason, registration_data); 941 success, errtype, err = self:set_affiliation(actor, item.attr.jid, item.attr.affiliation, reason, registration_data);
939 elseif item.attr.role and item.attr.nick and not item.attr.affiliation then 942 elseif item.attr.role and item.attr.nick and not item.attr.affiliation then
940 success, errtype, err = self:set_role(actor, self.jid.."/"..item.attr.nick, item.attr.role, reason); 943 success, errtype, err = self:set_role(actor, self.jid.."/"..item.attr.nick, item.attr.role, reason);