fix: send QUIT notifications for background idle cleanup
check / check (push) Successful in 2m2s

The background idle cleanup (DeleteStaleUsers) was removing stale
clients/sessions directly via SQL without sending QUIT notifications
to channel members. This caused timed-out users to silently disappear
from channels.

Now runCleanup identifies sessions that will be orphaned by the stale
client deletion and calls cleanupUser for each one first, ensuring
QUIT messages are sent to all channel members — matching the explicit
logout behavior.

Also refactored cleanupUser to accept context.Context instead of
*http.Request so it can be called from both HTTP handlers and the
background cleanup goroutine.
此提交包含在:
user
2026-03-01 06:33:15 -08:00
父節點 910a5c2606
當前提交 4d7b7618b2
共有 3 個檔案被更改,包括 70 行新增 和 4 行删除
+2 -4
查看文件
@@ -1405,7 +1405,7 @@ func (hdlr *Handlers) HandleLogout() http.HandlerFunc {
if remaining == 0 {
hdlr.cleanupUser(
request, sessionID, nick,
ctx, sessionID, nick,
)
}
@@ -1418,12 +1418,10 @@ func (hdlr *Handlers) HandleLogout() http.HandlerFunc {
// cleanupUser parts the user from all channels (notifying
// members) and deletes the session.
func (hdlr *Handlers) cleanupUser(
request *http.Request,
ctx context.Context,
sessionID int64,
nick string,
) {
ctx := request.Context()
channels, _ := hdlr.params.Database.
GetSessionChannels(ctx, sessionID)