mirror of
https://git.sr.ht/~emerson/reflectionircd
synced 2025-08-05 16:59:10 +00:00
make sure nicks are always unique
This commit is contained in:
parent
ac936f8c11
commit
0d91166f01
1 changed files with 12 additions and 4 deletions
|
@ -52,16 +52,24 @@ export class IRCUser {
|
|||
if (maybeMatrixUser) {
|
||||
return maybeMatrixUser;
|
||||
}
|
||||
let potentialNick = mxid.split(":")[0].substring(1);
|
||||
const localPart = mxid.split(":")[0].substring(1)
|
||||
if (!this.nickToMatrixUser.has(localPart)) {
|
||||
const newMatrixUser = new MatrixUser(mxid, localPart);
|
||||
this.matrixUsers.set(mxid, newMatrixUser);
|
||||
this.nickToMatrixUser.set(localPart, newMatrixUser);
|
||||
return newMatrixUser;
|
||||
}
|
||||
const homeserver = mxid.split(":")[1];
|
||||
const homeserverArray = homeserver.split('.');
|
||||
const baseDomainNum = homeserverArray.length - 2;
|
||||
let potentialNick = `${localPart}-${homeserverArray[baseDomainNum]}`;
|
||||
if (!this.nickToMatrixUser.has(potentialNick)) {
|
||||
const newMatrixUser = new MatrixUser(mxid, potentialNick);
|
||||
this.matrixUsers.set(mxid, newMatrixUser);
|
||||
this.nickToMatrixUser.set(potentialNick, newMatrixUser);
|
||||
return newMatrixUser;
|
||||
}
|
||||
const homeserverArray = mxid.split(":")[1].split('.');
|
||||
const baseDomainNum = homeserverArray.length - 2;
|
||||
potentialNick = `${potentialNick}-${homeserverArray[baseDomainNum]}`;
|
||||
potentialNick = `${localPart}-${homeserver}`;
|
||||
const newMatrixUser = new MatrixUser(mxid, potentialNick);
|
||||
this.matrixUsers.set(mxid, newMatrixUser);
|
||||
this.nickToMatrixUser.set(potentialNick, newMatrixUser);
|
||||
|
|
Loading…
Add table
Reference in a new issue