1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-16 18:01:37 +00:00

Add new API endpoint: /entries/{entryID}/save

This commit is contained in:
Jean Khawand 2023-07-28 22:56:59 +02:00 committed by GitHub
parent 3bac768cda
commit de8ceb21ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 683 additions and 1 deletions

View file

@ -14,6 +14,7 @@ import (
"miniflux.app/config"
"miniflux.app/http/request"
"miniflux.app/http/response/json"
"miniflux.app/integration"
"miniflux.app/model"
"miniflux.app/proxy"
"miniflux.app/reader/processor"
@ -197,6 +198,40 @@ func (h *handler) toggleBookmark(w http.ResponseWriter, r *http.Request) {
json.NoContent(w, r)
}
func (h *handler) saveEntry(w http.ResponseWriter, r *http.Request) {
entryID := request.RouteInt64Param(r, "entryID")
builder := h.store.NewEntryQueryBuilder(request.UserID(r))
builder.WithEntryID(entryID)
builder.WithoutStatus(model.EntryStatusRemoved)
// check if user has save entry enabled
if !h.store.HasSaveEntry(request.UserID(r)) {
json.BadRequest(w, r, errors.New("at least one enabled integration is required"))
return
}
entry, err := builder.GetEntry()
if err != nil {
json.ServerError(w, r, err)
return
}
if entry == nil {
json.NotFound(w, r)
return
}
settings, err := h.store.Integration(request.UserID(r))
if err != nil {
json.ServerError(w, r, err)
return
}
go func() {
integration.SendEntry(entry, settings)
}()
json.NoContent(w, r)
}
func (h *handler) fetchContent(w http.ResponseWriter, r *http.Request) {
loggedUserID := request.UserID(r)
entryID := request.RouteInt64Param(r, "entryID")