3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-25 21:39:25 +01:00

rename a variable

This commit is contained in:
Shivaram Lingamneni 2020-03-19 05:09:25 -04:00
parent ca3be51028
commit b32dd5ce33

View File

@ -117,7 +117,7 @@ func (clients *ClientManager) Resume(oldClient *Client, session *Session) (err e
func (clients *ClientManager) SetNick(client *Client, session *Session, newNick string) (setNick string, err error) { func (clients *ClientManager) SetNick(client *Client, session *Session, newNick string) (setNick string, err error) {
config := client.server.Config() config := client.server.Config()
var newcfnick, newSkeleton string var newCfNick, newSkeleton string
client.stateMutex.RLock() client.stateMutex.RLock()
account := client.account account := client.account
@ -139,7 +139,7 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
return "", errNickAccountMismatch return "", errNickAccountMismatch
} }
newNick = accountName newNick = accountName
newcfnick = account newCfNick = account
newSkeleton, err = Skeleton(newNick) newSkeleton, err = Skeleton(newNick)
if err != nil { if err != nil {
return "", errNicknameInvalid return "", errNicknameInvalid
@ -151,23 +151,23 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
} }
if account == "" && config.Accounts.NickReservation.ForceGuestFormat { if account == "" && config.Accounts.NickReservation.ForceGuestFormat {
newcfnick, err = CasefoldName(newNick) newCfNick, err = CasefoldName(newNick)
if err != nil { if err != nil {
return "", errNicknameInvalid return "", errNicknameInvalid
} }
if !config.Accounts.NickReservation.guestRegexpFolded.MatchString(newcfnick) { if !config.Accounts.NickReservation.guestRegexpFolded.MatchString(newCfNick) {
newNick = strings.Replace(config.Accounts.NickReservation.GuestFormat, "*", newNick, 1) newNick = strings.Replace(config.Accounts.NickReservation.GuestFormat, "*", newNick, 1)
newcfnick = "" // re-fold it below newCfNick = "" // re-fold it below
} }
} }
if newcfnick == "" { if newCfNick == "" {
newcfnick, err = CasefoldName(newNick) newCfNick, err = CasefoldName(newNick)
} }
if err != nil { if err != nil {
return "", errNicknameInvalid return "", errNicknameInvalid
} }
if len(newNick) > config.Limits.NickLen || len(newcfnick) > config.Limits.NickLen { if len(newNick) > config.Limits.NickLen || len(newCfNick) > config.Limits.NickLen {
return "", errNicknameInvalid return "", errNicknameInvalid
} }
newSkeleton, err = Skeleton(newNick) newSkeleton, err = Skeleton(newNick)
@ -175,11 +175,11 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
return "", errNicknameInvalid return "", errNicknameInvalid
} }
if restrictedCasefoldedNicks[newcfnick] || restrictedSkeletons[newSkeleton] { if restrictedCasefoldedNicks[newCfNick] || restrictedSkeletons[newSkeleton] {
return "", errNicknameInvalid return "", errNicknameInvalid
} }
reservedAccount, method := client.server.accounts.EnforcementStatus(newcfnick, newSkeleton) reservedAccount, method := client.server.accounts.EnforcementStatus(newCfNick, newSkeleton)
if method == NickEnforcementStrict && reservedAccount != "" && reservedAccount != account { if method == NickEnforcementStrict && reservedAccount != "" && reservedAccount != account {
return "", errNicknameReserved return "", errNicknameReserved
} }
@ -201,7 +201,7 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
clients.Lock() clients.Lock()
defer clients.Unlock() defer clients.Unlock()
currentClient := clients.byNick[newcfnick] currentClient := clients.byNick[newCfNick]
// the client may just be changing case // the client may just be changing case
if currentClient != nil && currentClient != client && session != nil { if currentClient != nil && currentClient != client && session != nil {
// these conditions forbid reattaching to an existing session: // these conditions forbid reattaching to an existing session:
@ -234,9 +234,9 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
} }
clients.removeInternal(client) clients.removeInternal(client)
clients.byNick[newcfnick] = client clients.byNick[newCfNick] = client
clients.bySkeleton[newSkeleton] = client clients.bySkeleton[newSkeleton] = client
client.updateNick(newNick, newcfnick, newSkeleton) client.updateNick(newNick, newCfNick, newSkeleton)
return newNick, nil return newNick, nil
} }