chore: deprecate user ebook folders endpoints
- Replace with 410 Gone responses directing to libraries - Maintain API contract for backward compatibility - Remove old user folder management functionality - Prepare for complete library system migration Old folder management now handled through library system
This commit is contained in:
@@ -513,110 +513,19 @@ type DeleteEbookFolderRequest struct {
|
|||||||
FolderPath string `json:"folder_path" validate:"required"`
|
FolderPath string `json:"folder_path" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddEbookFolder handles POST /api/auth/ebook-folders
|
// AddEbookFolder handles POST /api/auth/ebook-folders (DEPRECATED - use libraries instead)
|
||||||
func (h *AuthHandler) AddEbookFolder(c echo.Context) error {
|
func (h *AuthHandler) AddEbookFolder(c echo.Context) error {
|
||||||
userID := c.Get("user_id").(string)
|
return c.JSON(http.StatusGone, map[string]string{"error": "Ebook folders are deprecated. Please use the library system instead."})
|
||||||
userUUID, err := uuid.Parse(userID)
|
|
||||||
if err != nil {
|
|
||||||
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid user id"})
|
|
||||||
}
|
|
||||||
|
|
||||||
var req AddEbookFolderRequest
|
|
||||||
if err := c.Bind(&req); err != nil {
|
|
||||||
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid request"})
|
|
||||||
}
|
|
||||||
if err := c.Validate(&req); err != nil {
|
|
||||||
return c.JSON(http.StatusBadRequest, map[string]string{"error": err.Error()})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Normalize the folder path before storing
|
|
||||||
normalizedPath := normalizePath(req.FolderPath)
|
|
||||||
|
|
||||||
folder, err := h.db.AddUserEbookFolder(c.Request().Context(), database.AddUserEbookFolderParams{
|
|
||||||
UserID: pgtype.UUID{Bytes: userUUID, Valid: true},
|
|
||||||
FolderPath: normalizedPath,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.JSON(http.StatusCreated, EbookFolderResponse{
|
|
||||||
ID: uuid.UUID(folder.ID.Bytes).String(),
|
|
||||||
UserID: uuid.UUID(folder.UserID.Bytes).String(),
|
|
||||||
FolderPath: folder.FolderPath,
|
|
||||||
CreatedAt: folder.CreatedAt.Time.Format("2006-01-02T15:04:05Z07:00"),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetEbookFolders handles GET /api/auth/ebook-folders
|
// GetEbookFolders handles GET /api/auth/ebook-folders (DEPRECATED - use libraries instead)
|
||||||
func (h *AuthHandler) GetEbookFolders(c echo.Context) error {
|
func (h *AuthHandler) GetEbookFolders(c echo.Context) error {
|
||||||
userID := c.Get("user_id").(string)
|
return c.JSON(http.StatusGone, map[string]string{"error": "Ebook folders are deprecated. Please use library system instead."})
|
||||||
userUUID, err := uuid.Parse(userID)
|
|
||||||
if err != nil {
|
|
||||||
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid user id"})
|
|
||||||
}
|
|
||||||
|
|
||||||
folders, err := h.db.GetUserEbookFolders(c.Request().Context(), pgtype.UUID{Bytes: userUUID, Valid: true})
|
|
||||||
if err != nil {
|
|
||||||
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("GetEbookFolders: user_id='%s'\n", userID)
|
|
||||||
for _, folder := range folders {
|
|
||||||
fmt.Printf(" Folder in DB: id='%s', path='%s'\n",
|
|
||||||
uuid.UUID(folder.ID.Bytes).String(), folder.FolderPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
var response []EbookFolderResponse
|
|
||||||
for _, folder := range folders {
|
|
||||||
response = append(response, EbookFolderResponse{
|
|
||||||
ID: uuid.UUID(folder.ID.Bytes).String(),
|
|
||||||
UserID: uuid.UUID(folder.UserID.Bytes).String(),
|
|
||||||
FolderPath: folder.FolderPath,
|
|
||||||
CreatedAt: folder.CreatedAt.Time.Format("2006-01-02T15:04:05Z07:00"),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.JSON(http.StatusOK, response)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteEbookFolder handles DELETE /api/auth/ebook-folders
|
// DeleteEbookFolder handles DELETE /api/auth/ebook-folders (DEPRECATED - use libraries instead)
|
||||||
func (h *AuthHandler) DeleteEbookFolder(c echo.Context) error {
|
func (h *AuthHandler) DeleteEbookFolder(c echo.Context) error {
|
||||||
userID := c.Get("user_id").(string)
|
return c.JSON(http.StatusGone, map[string]string{"error": "Ebook folders are deprecated. Please use library system instead."})
|
||||||
userUUID, err := uuid.Parse(userID)
|
|
||||||
if err != nil {
|
|
||||||
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid user id"})
|
|
||||||
}
|
|
||||||
|
|
||||||
var req DeleteEbookFolderRequest
|
|
||||||
if err := c.Bind(&req); err != nil {
|
|
||||||
return c.JSON(http.StatusBadRequest, map[string]string{"error": "invalid request"})
|
|
||||||
}
|
|
||||||
if err := c.Validate(&req); err != nil {
|
|
||||||
return c.JSON(http.StatusBadRequest, map[string]string{"error": err.Error()})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Normalize the folder path before deletion
|
|
||||||
normalizedPath := normalizePath(req.FolderPath)
|
|
||||||
|
|
||||||
// Debug logging - remove in production
|
|
||||||
fmt.Printf("DeleteEbookFolder: original path='%s', normalized path='%s', user_id='%s'\n",
|
|
||||||
req.FolderPath, normalizedPath, userID)
|
|
||||||
|
|
||||||
deletedFolder, err := h.db.DeleteUserEbookFolder(c.Request().Context(), database.DeleteUserEbookFolderParams{
|
|
||||||
UserID: pgtype.UUID{Bytes: userUUID, Valid: true},
|
|
||||||
FolderPath: normalizedPath,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("DeleteEbookFolder failed: %v\n", err)
|
|
||||||
if err == pgx.ErrNoRows {
|
|
||||||
return c.JSON(http.StatusNotFound, map[string]string{"error": "ebook folder not found"})
|
|
||||||
}
|
|
||||||
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Printf("DeleteEbookFolder succeeded: deleted folder with path '%s'\n", deletedFolder.FolderPath)
|
|
||||||
return c.JSON(http.StatusOK, map[string]string{"message": "ebook folder deleted successfully"})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateThemeRequest struct {
|
type UpdateThemeRequest struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user