refactor: shared service layer, default IRC port, smaller functions
All checks were successful
check / check (push) Successful in 2m37s

Wire up service.Service in HTTP handlers and delegate cleanupUser to
svc.BroadcastQuit for consistent quit/part logic across transports.
Default IRC_LISTEN_ADDR to :6667, remove unused import, fix all lint
issues (dogsled, funcorder, wrapcheck, varnamelen, nolintlint).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
user
2026-03-25 13:39:32 -07:00
parent 42157a7b23
commit 2853dc8a1f
10 changed files with 1100 additions and 812 deletions

View File

@@ -3547,52 +3547,16 @@ func (hdlr *Handlers) HandleLogout() http.HandlerFunc {
}
// cleanupUser parts the user from all channels (notifying
// members) and deletes the session.
// members) and deletes the session via the shared service
// layer.
func (hdlr *Handlers) cleanupUser(
ctx context.Context,
sessionID int64,
nick string,
) {
channels, _ := hdlr.params.Database.
GetSessionChannels(ctx, sessionID)
notified := map[int64]bool{}
var quitDBID int64
if len(channels) > 0 {
quitDBID, _, _ = hdlr.params.Database.InsertMessage(
ctx, irc.CmdQuit, nick, "",
nil, nil, nil,
)
}
for _, chanInfo := range channels {
memberIDs, _ := hdlr.params.Database.
GetChannelMemberIDs(ctx, chanInfo.ID)
for _, mid := range memberIDs {
if mid != sessionID && !notified[mid] {
notified[mid] = true
_ = hdlr.params.Database.EnqueueToSession(
ctx, mid, quitDBID,
)
hdlr.broker.Notify(mid)
}
}
_ = hdlr.params.Database.PartChannel(
ctx, chanInfo.ID, sessionID,
)
_ = hdlr.params.Database.DeleteChannelIfEmpty(
ctx, chanInfo.ID,
)
}
_ = hdlr.params.Database.DeleteSession(ctx, sessionID)
hdlr.svc.BroadcastQuit(
ctx, sessionID, nick, "Connection closed",
)
}
// HandleUsersMe returns the current user's session info.