3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-13 07:29:30 +01:00

restore transition mechanism

This commit is contained in:
Shivaram Lingamneni 2020-07-12 16:31:51 -04:00
parent 6f8711da3b
commit 77184c1625
2 changed files with 12 additions and 0 deletions

View File

@ -122,6 +122,7 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
accountName := client.accountName
settings := client.accountSettings
registered := client.registered
realname := client.realname
client.stateMutex.RUnlock()
// recompute always-on status, because client.alwaysOn is not set for unregistered clients
@ -224,6 +225,10 @@ func (clients *ClientManager) SetNick(client *Client, session *Session, newNick
client.server.stats.AddRegistered(invisible, operator)
}
session.autoreplayMissedSince = lastSeen
// TODO: transition mechanism for #1065, clean this up eventually:
if currentClient.Realname() == "" {
currentClient.SetRealname(realname)
}
// successful reattach!
return newNick, nil, back
} else if currentClient == client && currentClient.Nick() == newNick {

View File

@ -430,6 +430,13 @@ func (client *Client) UpdateActive(session *Session) {
session.lastActive = now
}
func (client *Client) Realname() string {
client.stateMutex.RLock()
result := client.realname
client.stateMutex.RUnlock()
return result
}
func (channel *Channel) Name() string {
channel.stateMutex.RLock()
defer channel.stateMutex.RUnlock()