comparison plugins/muc/register.lib.lua @ 13300:b73547cfd736

muc.register: Clarify what's going on when enforcing nicknames Does this make it clearer what is going on?
author Kim Alvefur <zash@zash.se>
date Fri, 03 Nov 2023 21:13:34 +0100
parents 74b9e05af71e
children 9eee04a95a25
comparison
equal deleted inserted replaced
13299:20b7de7ab66a 13300:b73547cfd736
92 -- Check if the occupant has a reservation they must use 92 -- Check if the occupant has a reservation they must use
93 if enforce_nick then 93 if enforce_nick then
94 local nick = get_registered_nick(room, jid_bare(stanza.attr.from)); 94 local nick = get_registered_nick(room, jid_bare(stanza.attr.from));
95 if nick then 95 if nick then
96 if event.occupant then 96 if event.occupant then
97 -- someone is joining, force their nickname to the registered one
97 event.occupant.nick = jid_bare(event.occupant.nick) .. "/" .. nick; 98 event.occupant.nick = jid_bare(event.occupant.nick) .. "/" .. nick;
98 elseif event.dest_occupant.nick ~= jid_bare(event.dest_occupant.nick) .. "/" .. nick then 99 elseif event.dest_occupant.nick ~= jid_bare(event.dest_occupant.nick) .. "/" .. nick then
100 -- someone is trying to change nickname to something other than their registered nickname, can't have that
99 module:log("debug", "Attempt by %s to join as %s, but their reserved nick is %s", stanza.attr.from, requested_nick, nick); 101 module:log("debug", "Attempt by %s to join as %s, but their reserved nick is %s", stanza.attr.from, requested_nick, nick);
100 local reply = st.error_reply(stanza, "cancel", "not-acceptable", nil, room.jid):up(); 102 local reply = st.error_reply(stanza, "cancel", "not-acceptable", nil, room.jid):up();
101 origin.send(reply); 103 origin.send(reply);
102 return true; 104 return true;
103 end 105 end