diff --git a/internal/handler/admin.go b/internal/handler/admin.go index 7938801..58729de 100644 --- a/internal/handler/admin.go +++ b/internal/handler/admin.go @@ -144,10 +144,10 @@ func resetUserPasswordHandler(svc *service.Container) gin.HandlerFunc { return } if err := svc.Auth.ResetPassword(c.Request.Context(), c.Param("id"), req.Password); err != nil { - c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } - c.JSON(http.StatusOK, gin.H{"ok": true}) + c.Status(http.StatusNoContent) } } @@ -174,7 +174,7 @@ func writeUserMutationError(c *gin.Context, err error) { case errors.Is(err, service.ErrUserLimitReached): c.JSON(http.StatusBadRequest, gin.H{"error": "user limit reached: maximum 20 users"}) default: - c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) } } diff --git a/internal/handler/assistant.go b/internal/handler/assistant.go index 82053e2..a59c6a1 100644 --- a/internal/handler/assistant.go +++ b/internal/handler/assistant.go @@ -39,7 +39,7 @@ func createAssistantSessionHandler(svc *service.Container) gin.HandlerFunc { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } - c.JSON(http.StatusOK, sess) + c.JSON(http.StatusCreated, sess) } } diff --git a/internal/handler/backup.go b/internal/handler/backup.go index c9c72c0..9643cbb 100644 --- a/internal/handler/backup.go +++ b/internal/handler/backup.go @@ -16,7 +16,7 @@ func createBackupHandler(svc *service.Container) gin.HandlerFunc { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } - c.JSON(http.StatusOK, info) + c.JSON(http.StatusCreated, info) } } diff --git a/internal/handler/downloads.go b/internal/handler/downloads.go index a391120..29fa0f5 100644 --- a/internal/handler/downloads.go +++ b/internal/handler/downloads.go @@ -73,11 +73,11 @@ func addDownloadHandler(svc *service.Container) gin.HandlerFunc { }, fallbackTitle, "") t, err := svc.Downloads.AddDownloadWithMeta(c.Request.Context(), uid.(string), realURL, req.SavePath, meta) if err != nil { - c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } svc.Audit.Record(c.Request.Context(), uid.(string), "download.add", redactDownloadURL(realURL), c.ClientIP(), "") - c.JSON(http.StatusOK, t) + c.JSON(http.StatusCreated, t) } } diff --git a/internal/handler/media.go b/internal/handler/media.go index e64a344..4da8128 100644 --- a/internal/handler/media.go +++ b/internal/handler/media.go @@ -51,7 +51,7 @@ func createLibraryHandler(svc *service.Container) gin.HandlerFunc { } l, err := svc.Media.CreateLibrary(c.Request.Context(), req.Name, req.Path, req.Type) if err != nil { - c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } uid, _ := c.Get("ctx_user_id")