From 67f18892af4784b649fc93ad857856631e7116a2 Mon Sep 17 00:00:00 2001 From: senke Date: Tue, 14 Apr 2026 18:11:07 +0200 Subject: [PATCH] =?UTF-8?q?refactor(backend):=20J3=20=E2=80=94=20remove=20?= =?UTF-8?q?3=20deprecated=20unused=20handlers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cleanup of dead code marked // DEPRECATED in veza-backend-api/internal/handlers. Each symbol was verified to have zero callers across the codebase before deletion (go build ./... + go vet ./... + go test ./internal/... pass). Deleted: - UploadResponse type (upload.go) — callers use upload.StandardUploadResponse - BindJSON method on CommonHandler (common.go) — callers use BindAndValidateJSON - sendMessage method on *Client (playback_websocket_handler.go) — internal WS broadcast now goes through sendStandardizedMessage Kept as tech debt (still actively used, refactor out of J3 scope): - UploadRequest type (upload.go:23) — used by upload handler, refactor requires migrating to upload.StandardUploadRequest with multipart binding - BroadcastMessage type (playback_websocket_handler.go:53) — still the channel type for legacy playback broadcasts and referenced in tests Also in this day (already committed in parallel): - veza-backend-api/internal/api/handlers/two_factor_handlers.go deletion (had //go:build ignore, zero callers) — bundled into 7fa314866 by concurrent work on .github/workflows/*.yml seed-v2 investigation: - No Go source for seed-v2 found — it was only a compiled binary already purged in J1 (0e7097ed1). No code action needed. Refs: AUDIT_REPORT.md §8.1, §12 item 1-2 --- veza-backend-api/internal/handlers/common.go | 13 ------------ .../handlers/playback_websocket_handler.go | 21 ------------------- veza-backend-api/internal/handlers/upload.go | 14 ------------- 3 files changed, 48 deletions(-) diff --git a/veza-backend-api/internal/handlers/common.go b/veza-backend-api/internal/handlers/common.go index 9e83514c7..bc8a30bbb 100644 --- a/veza-backend-api/internal/handlers/common.go +++ b/veza-backend-api/internal/handlers/common.go @@ -195,19 +195,6 @@ func BuildPaginationDataWithCursor(limit int, total int64, nextCursor, prevCurso } } -// BindJSON lie les données JSON de la requête à une structure -// DEPRECATED: Utiliser BindAndValidateJSON à la place pour une gestion d'erreurs robuste -func (h *CommonHandler) BindJSON(c *gin.Context, obj interface{}) error { - if err := c.ShouldBindJSON(obj); err != nil { - h.logger.Warn("Failed to bind JSON", - zap.Error(err), - zap.String("request_id", c.GetString("request_id")), - ) - return err - } - return nil -} - // BindAndValidateJSON lie et valide les données JSON de la requête de manière robuste // P0: JSON Hardening - Garantit qu'aucune erreur de parsing/validation ne passe silencieusement // diff --git a/veza-backend-api/internal/handlers/playback_websocket_handler.go b/veza-backend-api/internal/handlers/playback_websocket_handler.go index 439e1e423..9598138dc 100644 --- a/veza-backend-api/internal/handlers/playback_websocket_handler.go +++ b/veza-backend-api/internal/handlers/playback_websocket_handler.go @@ -252,27 +252,6 @@ func (c *Client) writePump() { } } -// sendMessage envoie un message au client (legacy format) -// DEPRECATED: Use sendStandardizedMessage instead -func (c *Client) sendMessage(msg *BroadcastMessage) { - c.mu.Lock() - defer c.mu.Unlock() - - data, err := json.Marshal(msg) - if err != nil { - c.handler.logger.Error("Failed to marshal message", - zap.Error(err), - zap.String("user_id", c.userID.String())) - return - } - - select { - case c.send <- data: - default: - close(c.send) - } -} - // sendStandardizedMessage envoie un message au client avec format standardisé // INT-014: Standardized WebSocket message format func (c *Client) sendStandardizedMessage(msg *wsmsg.WebSocketMessage) { diff --git a/veza-backend-api/internal/handlers/upload.go b/veza-backend-api/internal/handlers/upload.go index fe52afa20..0aefbe271 100644 --- a/veza-backend-api/internal/handlers/upload.go +++ b/veza-backend-api/internal/handlers/upload.go @@ -29,20 +29,6 @@ type UploadRequest struct { Metadata string `form:"metadata"` } -// UploadResponse réponse pour upload -// DEPRECATED: Use upload.StandardUploadResponse instead -// INT-015: Kept for backward compatibility during migration -type UploadResponse struct { - ID uuid.UUID `json:"id"` - TrackID uuid.UUID `json:"track_id"` - FileName string `json:"file_name"` - FileSize int64 `json:"file_size"` - FileType string `json:"file_type"` - Checksum string `json:"checksum"` - Status string `json:"status"` - CreatedAt time.Time `json:"created_at"` -} - // UploadValidatorInterface définit les méthodes nécessaires pour UploadValidator type UploadValidatorInterface interface { ValidateFile(ctx context.Context, fileHeader *multipart.FileHeader, fileType string) (*services.ValidationResult, error)