Make an IRC listener connection follow its session's nick (closes #184)
check / check (push) Waiting to run

When the session's nick was changed from another client, such as the
web client over the HTTP API, the IRC listener connection kept the old
nick and sent its messages, joins and later NICK changes under it. The
relay now gives the connection the new nick when it delivers a NICK
change whose old nick is the connection's own: nicks are unique, so its
own session made that change. As the relay goroutine can now change the
nick, the command handlers read it under the connection's lock, through
currentNick, as the relay already did.

Model: opus-5-5
This commit is contained in:
2026-10-21 13:35:02 +00:00
parent 129d87d578
commit 2a2bd820ec
4 changed files with 110 additions and 43 deletions
+12 -1
View File
@@ -230,11 +230,22 @@ func (c *Conn) deliverPart(msg *db.IRCMessage, text string) {
}
}
// deliverNickChange sends a NICK change notification.
// deliverNickChange sends a NICK change notification. When
// the old nick is the connection's own, the change was made
// from another client of its session, as nicks are unique,
// and the connection takes the new nick too.
func (c *Conn) deliverNickChange(
msg *db.IRCMessage,
newNick string,
) {
c.mu.Lock()
if msg.From == c.nick {
c.nick = newNick
}
c.mu.Unlock()
prefix := msg.From + "!" + msg.From + "@*"
c.send(FormatMessage(prefix, "NICK", newNick))