mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
fix(server): resolve golangci-lint contextcheck, errcheck, gocritic findings
contextcheck: add ctx context.Context as first param to ListVisibleChannels,
BlockUser, CreateDM, CreateInvite, UpdateProfile, SendMessage; pass r.Context()
from HTTP handlers and ctx from WS handler; replace context.Background() in
telemetry spans with the propagated ctx.
errcheck: suppress justified Close() errors — defer func(){ _ = rows.Close() }()
in sqlite_events.go (idiomatic; rows.Err() checked), _ = resp.Body.Close() in
host_http.go (body fully consumed), _ = f.Close() in host_ui.go (read-only fd).
gocritic/rangeValCopy: rewrite for _, ch := range all (line 60) to indexed loop
in ChannelService.ListVisibleChannels to avoid 144-byte per-iteration copy.
This commit is contained in:
@@ -73,7 +73,7 @@ func handleCreateDM(svc *service.Services) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
result, err := svc.DMs.CreateDM(user.ID, req.RecipientID)
|
||||
result, err := svc.DMs.CreateDM(r.Context(), user.ID, req.RecipientID)
|
||||
if err != nil {
|
||||
writeServiceError(w, err)
|
||||
return
|
||||
@@ -169,7 +169,7 @@ func handleBlockUser(svc *service.Services) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
if err := svc.Blocks.BlockUser(user.ID, targetID); err != nil {
|
||||
if err := svc.Blocks.BlockUser(r.Context(), user.ID, targetID); err != nil {
|
||||
writeServiceError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user