From bdb9132b853676d861bacd51911df6f141c81044 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Mon, 26 Oct 2026 13:59:22 -0400 Subject: [PATCH] chore(auth): drop dead UpdateProfileRequest; rename shared struct MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The combined profile handler (self-edit PUT /api/auth/profile and admin PUT /api/auth/profile/:id) binds one struct for both paths — and it's the admin-named one. Its twin UpdateProfileRequest had zero references left. Delete it and rename AdminUpdateUserRequest to ProfileUpdateRequest so the name matches who actually binds it; the comments describing field semantics now stand on their own instead of pointing at the deleted twin. Wire format (json/form tags) unchanged; docs schema registration follows the rename. --- internal/docs/schema.go | 2 +- internal/handlers/auth.go | 19 ++++--------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/internal/docs/schema.go b/internal/docs/schema.go index be02e4f7..c6a6849a 100644 --- a/internal/docs/schema.go +++ b/internal/docs/schema.go @@ -705,7 +705,7 @@ var Schemas = map[string]Schema{ }, "PUT /api/auth/profile": { // Shared with admin variant (PUT /auth/profile/:id). - Request: handlers.AdminUpdateUserRequest{}, + Request: handlers.ProfileUpdateRequest{}, Response: json.RawMessage(`{"message": ""}`), }, "DELETE /api/auth/profile": { diff --git a/internal/handlers/auth.go b/internal/handlers/auth.go index 51ff463b..b3a6b05b 100644 --- a/internal/handlers/auth.go +++ b/internal/handlers/auth.go @@ -124,19 +124,7 @@ type UserProfile struct { DefaultAudioSpeed float64 `json:"default_audio_speed,omitempty"` } -type UpdateProfileRequest struct { - Username string `json:"username,omitempty" form:"username" validate:"omitempty,min=3,max=50"` - Email string `json:"email,omitempty" form:"email" validate:"omitempty,email"` - FirstName string `json:"first_name,omitempty" form:"first_name" validate:"omitempty,max=100"` - LastName string `json:"last_name,omitempty" form:"last_name" validate:"omitempty,max=100"` - Theme string `json:"theme,omitempty" form:"theme" validate:"omitempty"` - Timezone string `json:"timezone,omitempty" form:"timezone" validate:"omitempty"` - // Per the SPEEDS list bounds; the profile select always sends it, - // JSON clients omit it (0 = untouched). - DefaultAudioSpeed float64 `json:"default_audio_speed,omitempty" form:"default_audio_speed" validate:"omitempty,min=0.25,max=4"` -} - -type AdminUpdateUserRequest struct { +type ProfileUpdateRequest struct { Username string `json:"username,omitempty" form:"username" validate:"omitempty,min=3,max=50"` Email string `json:"email,omitempty" form:"email" validate:"omitempty,email"` FirstName string `json:"first_name,omitempty" form:"first_name" validate:"omitempty,max=100"` @@ -144,7 +132,8 @@ type AdminUpdateUserRequest struct { Theme string `json:"theme,omitempty" form:"theme" validate:"omitempty"` Timezone string `json:"timezone,omitempty" form:"timezone" validate:"omitempty"` Role string `json:"role,omitempty" form:"role" validate:"omitempty,oneof=user admin"` - // Same semantics as UpdateProfileRequest.DefaultAudioSpeed. + // Per the SPEEDS list bounds; the profile select always sends it, + // JSON clients omit it (0 = untouched). DefaultAudioSpeed float64 `json:"default_audio_speed,omitempty" form:"default_audio_speed" validate:"omitempty,min=0.25,max=4"` } @@ -581,7 +570,7 @@ func (h *AuthHandler) UpdateProfile(c *echo.Context) error { targetUserUUID = currentUser.ID } - var req AdminUpdateUserRequest + var req ProfileUpdateRequest if err := c.Bind(&req); err != nil { return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid request"}) }