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. Now,
whenever the relay passes on a NICK line, and after the connection's
own NICK, the connection takes the nick its session holds in the
database, through loadSessionNick. It does not go by the line's old
nick, as the connection may have taken that nick after another user
gave it up. As the relay goroutine can now change the nick, the command
handlers read it under the connection's lock, through currentNick.

Model: opus-5-5
This commit is contained in:
2026-10-21 15:29:22 +00:00
parent 129d87d578
commit fcdb885e06
5 changed files with 187 additions and 48 deletions
+19
View File
@@ -264,6 +264,25 @@ func (database *Database) GetSessionByNick(
return sessionID, nil
}
// GetSessionNick returns the nick a session holds.
func (database *Database) GetSessionNick(
ctx context.Context,
sessionID int64,
) (string, error) {
var nick string
err := database.conn.QueryRowContext(
ctx,
"SELECT nick FROM sessions WHERE id = ?",
sessionID,
).Scan(&nick)
if err != nil {
return "", fmt.Errorf("get session nick: %w", err)
}
return nick, nil
}
// SessionHostInfo holds the username, hostname, and IP
// for a session.
type SessionHostInfo struct {