Keep active IRC listener users from expiring (closes #121)
check / check (push) Waiting to run

Every command a registered IRC listener client sends, PING and PONG
included, now sets last_seen on its session and its client, so the
idle cleanup no longer removes an IRC user who is still active; one
who sends nothing for SESSION_IDLE_TIMEOUT is still removed. The two
UPDATEs that GetSessionByToken ran for every authenticated HTTP API
request move into UpdateLastSeen, which both transports now call. The
IRC listener refreshes on every command, with no interval between
writes: that is what every HTTP API request already costs. README.md
describes last_seen to match.

Model: opus-5-5
This commit is contained in:
2026-10-08 07:00:55 +00:00
parent 0f2e63d0cc
commit 95e4a8fd8f
4 changed files with 70 additions and 5 deletions
+24 -3
View File
@@ -204,21 +204,42 @@ func (database *Database) GetSessionByToken(
)
}
_ = database.UpdateLastSeen(ctx, sessionID, clientID)
return sessionID, clientID, nick, nil
}
// UpdateLastSeen sets last_seen to now on a session and on
// one of its clients, so that the idle cleanup keeps them.
func (database *Database) UpdateLastSeen(
ctx context.Context,
sessionID, clientID int64,
) error {
now := time.Now()
_, _ = database.conn.ExecContext(
_, err := database.conn.ExecContext(
ctx,
"UPDATE sessions SET last_seen = ? WHERE id = ?",
now, sessionID,
)
if err != nil {
return fmt.Errorf(
"update session last_seen: %w", err,
)
}
_, _ = database.conn.ExecContext(
_, err = database.conn.ExecContext(
ctx,
"UPDATE clients SET last_seen = ? WHERE id = ?",
now, clientID,
)
if err != nil {
return fmt.Errorf(
"update client last_seen: %w", err,
)
}
return sessionID, clientID, nick, nil
return nil
}
// GetSessionByNick returns session id for a given nick.