Broadcast a session's QUIT once when its clients leave together (closes #154)
check / check (push) Canceled after 0s

Logout deleted the client, counted the session's clients and ran
BroadcastQuit as separate statements, and BroadcastQuit read the peers,
parted, deleted empty channels and deleted the session separately too.
Two logouts or QUITs of one session at once both sent its QUIT, and a
JOIN landing between a part and the channel's deletion got into a +k
channel without the key.

db.QuitSession now does all of that in one transaction, parting each
channel as PartChannelAndDeleteIfEmpty does, and reports whether it
deleted the session; only that caller sends the QUIT. db.LogoutClient
deletes the client and counts the rest in the same transaction.

Model: opus-5-5
This commit is contained in:
2026-10-20 21:09:39 +00:00
parent 108e381428
commit 6ed3fee559
6 changed files with 453 additions and 112 deletions
+8 -6
View File
@@ -2569,12 +2569,14 @@ issues) and simpler than UUIDs (integer comparison vs. string comparison).
- **Sessions**: Both anonymous and password-protected sessions are deleted on
`QUIT` or when the last client logs out (`POST /api/v1/logout` with no
remaining clients triggers session cleanup). There is no distinction between
session types in the cleanup path — `handleQuit` and `cleanupUser` both call
`DeleteSession` unconditionally. Idle clients are automatically removed after
`SESSION_IDLE_TIMEOUT` (default 30 days) without an authenticated HTTP API
request or, on the IRC listener, a command — the server runs a background
cleanup loop that, for a session left with no clients, parts the user from all
channels, broadcasts QUIT, and releases the nick.
session types in the cleanup path: the session is parted from its channels and
deleted in one database transaction, and when several QUITs or logouts end one
session at once, only the one that deletes it broadcasts QUIT. Idle clients
are automatically removed after `SESSION_IDLE_TIMEOUT` (default 30 days)
without an authenticated HTTP API request or, on the IRC listener, a command —
the server runs a background cleanup loop that, for a session left with no
clients, parts the user from all channels, broadcasts QUIT, and releases the
nick.
- **Clients**: Individual client auth cookies are invalidated on
`POST /api/v1/logout`. A session can have multiple clients; removing one
doesn't affect others. However, when the last client is removed (via logout),