entry_update_status.go 764 B

12345678910111213141516171819202122232425262728293031323334
  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. "errors"
  7. "net/http"
  8. "miniflux.app/http/request"
  9. "miniflux.app/http/response/json"
  10. )
  11. func (h *handler) updateEntriesStatus(w http.ResponseWriter, r *http.Request) {
  12. entryIDs, status, err := decodeEntryStatusPayload(r.Body)
  13. if err != nil {
  14. json.BadRequest(w, r, err)
  15. return
  16. }
  17. if len(entryIDs) == 0 {
  18. json.BadRequest(w, r, errors.New("The list of entry IDs is empty"))
  19. return
  20. }
  21. err = h.store.SetEntriesStatus(request.UserID(r), entryIDs, status)
  22. if err != nil {
  23. json.ServerError(w, r, err)
  24. return
  25. }
  26. json.OK(w, r, "OK")
  27. }