entry_save.go 1005 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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/json"
  8. "miniflux.app/v2/internal/integration"
  9. "miniflux.app/v2/internal/model"
  10. )
  11. func (h *handler) saveEntry(w http.ResponseWriter, r *http.Request) {
  12. entryID := request.RouteInt64Param(r, "entryID")
  13. builder := h.store.NewEntryQueryBuilder(request.UserID(r))
  14. builder.WithEntryID(entryID)
  15. builder.WithoutStatus(model.EntryStatusRemoved)
  16. entry, err := builder.GetEntry()
  17. if err != nil {
  18. json.ServerError(w, r, err)
  19. return
  20. }
  21. if entry == nil {
  22. json.NotFound(w, r)
  23. return
  24. }
  25. userIntegrations, err := h.store.Integration(request.UserID(r))
  26. if err != nil {
  27. json.ServerError(w, r, err)
  28. return
  29. }
  30. go integration.SendEntry(entry, userIntegrations)
  31. json.Created(w, r, map[string]string{"message": "saved"})
  32. }