From 2def06b98f94a6c203acefc555fa42cfc7142733 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Thu, 28 May 2020 17:55:53 -0400 Subject: [PATCH] fix #1076 --- irc/client.go | 2 +- irc/monitor.go | 6 ++---- irc/nickname.go | 6 +++++- irc/server.go | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/irc/client.go b/irc/client.go index 4445ad5c..b2b2a0e6 100644 --- a/irc/client.go +++ b/irc/client.go @@ -1333,7 +1333,7 @@ func (client *Client) destroy(session *Session) { // alert monitors if registered { - client.server.monitorManager.AlertAbout(client, false) + client.server.monitorManager.AlertAbout(details.nick, details.nickCasefolded, false) } // clean up monitor state client.server.monitorManager.RemoveAll(client) diff --git a/irc/monitor.go b/irc/monitor.go index b053b21b..e9cde7c4 100644 --- a/irc/monitor.go +++ b/irc/monitor.go @@ -25,9 +25,7 @@ func (mm *MonitorManager) Initialize() { } // AlertAbout alerts everyone monitoring `client`'s nick that `client` is now {on,off}line. -func (manager *MonitorManager) AlertAbout(client *Client, online bool) { - cfnick := client.NickCasefolded() - nick := client.Nick() +func (manager *MonitorManager) AlertAbout(nick, cfnick string, online bool) { var watchers []*Client // safely copy the list of clients watching our nick manager.RLock() @@ -42,7 +40,7 @@ func (manager *MonitorManager) AlertAbout(client *Client, online bool) { } for _, mClient := range watchers { - mClient.Send(nil, client.server.name, command, mClient.Nick(), nick) + mClient.Send(nil, mClient.server.name, command, mClient.Nick(), nick) } } diff --git a/irc/nickname.go b/irc/nickname.go index 9c54120f..20f493f9 100644 --- a/irc/nickname.go +++ b/irc/nickname.go @@ -89,7 +89,11 @@ func performNickChange(server *Server, client *Client, target *Client, session * } if target.Registered() { - client.server.monitorManager.AlertAbout(target, true) + newCfnick := target.NickCasefolded() + if newCfnick != details.nickCasefolded { + client.server.monitorManager.AlertAbout(details.nick, details.nickCasefolded, false) + client.server.monitorManager.AlertAbout(assignedNickname, newCfnick, true) + } target.nickTimer.Touch(rb) } // else: these will be deferred to the end of registration (see #572) return nil diff --git a/irc/server.go b/irc/server.go index bce3a101..17a279a1 100644 --- a/irc/server.go +++ b/irc/server.go @@ -271,7 +271,7 @@ func (server *Server) tryRegister(c *Client, session *Session) (exiting bool) { // count new user in statistics server.stats.Register() - server.monitorManager.AlertAbout(c, true) + server.monitorManager.AlertAbout(c.Nick(), c.NickCasefolded(), true) server.playRegistrationBurst(session) return false