Make an IRC listener connection follow its session's nick (closes #184)
check / check (push) Waiting to run
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, the connection first takes the nick its session holds in the database. 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, as the relay already did. Model: opus-5-5
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user