category_remove_feed.go 870 B

123456789101112131415161718192021222324252627282930313233
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package ui // import "miniflux.app/v2/internal/ui"
  4. import (
  5. "net/http"
  6. "miniflux.app/v2/internal/http/request"
  7. "miniflux.app/v2/internal/http/response"
  8. )
  9. func (h *handler) removeCategoryFeed(w http.ResponseWriter, r *http.Request) {
  10. feedID := request.RouteInt64Param(r, "feedID")
  11. categoryID := request.RouteInt64Param(r, "categoryID")
  12. exists, err := h.store.CategoryFeedExists(request.UserID(r), categoryID, feedID)
  13. if err != nil {
  14. response.HTMLServerError(w, r, err)
  15. return
  16. }
  17. if !exists {
  18. response.HTMLNotFound(w, r)
  19. return
  20. }
  21. if err := h.store.RemoveFeed(request.UserID(r), feedID); err != nil {
  22. response.HTMLServerError(w, r, err)
  23. return
  24. }
  25. response.HTMLRedirect(w, r, h.routePath("/category/%d/feeds", categoryID))
  26. }