entry_scraper.go 965 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. "miniflux.app/http/request"
  8. "miniflux.app/http/response/json"
  9. "miniflux.app/model"
  10. "miniflux.app/reader/processor"
  11. )
  12. func (h *handler) fetchContent(w http.ResponseWriter, r *http.Request) {
  13. entryID := request.RouteInt64Param(r, "entryID")
  14. builder := h.store.NewEntryQueryBuilder(request.UserID(r))
  15. builder.WithEntryID(entryID)
  16. builder.WithoutStatus(model.EntryStatusRemoved)
  17. entry, err := builder.GetEntry()
  18. if err != nil {
  19. json.ServerError(w, r, err)
  20. return
  21. }
  22. if entry == nil {
  23. json.NotFound(w, r)
  24. return
  25. }
  26. if err := processor.ProcessEntryWebPage(entry); err != nil {
  27. json.ServerError(w, r, err)
  28. return
  29. }
  30. h.store.UpdateEntryContent(entry)
  31. json.OK(w, r, map[string]string{"content": entry.Content})
  32. }