category_mark_as_read.go 853 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright 2018 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package ui // import "miniflux.app/ui"
  5. import (
  6. "net/http"
  7. "time"
  8. "miniflux.app/http/request"
  9. "miniflux.app/http/response/html"
  10. "miniflux.app/http/route"
  11. )
  12. func (h *handler) markCategoryAsRead(w http.ResponseWriter, r *http.Request) {
  13. userID := request.UserID(r)
  14. categoryID := request.RouteInt64Param(r, "categoryID")
  15. category, err := h.store.Category(userID, categoryID)
  16. if err != nil {
  17. html.ServerError(w, r, err)
  18. return
  19. }
  20. if category == nil {
  21. html.NotFound(w, r)
  22. return
  23. }
  24. if err = h.store.MarkCategoryAsRead(userID, categoryID, time.Now()); err != nil {
  25. html.ServerError(w, r, err)
  26. return
  27. }
  28. html.Redirect(w, r, route.Path(h.router, "categories"))
  29. }