2023-06-19 14:42:47 -07:00
|
|
|
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2018-04-29 16:35:04 -07:00
|
|
|
|
2023-08-10 19:46:45 -07:00
|
|
|
package ui // import "miniflux.app/v2/internal/ui"
|
2018-04-29 16:35:04 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2023-08-10 19:46:45 -07:00
|
|
|
"miniflux.app/v2/internal/http/request"
|
|
|
|
"miniflux.app/v2/internal/http/response/json"
|
|
|
|
"miniflux.app/v2/internal/integration"
|
|
|
|
"miniflux.app/v2/internal/model"
|
2018-04-29 16:35:04 -07:00
|
|
|
)
|
|
|
|
|
2018-11-11 11:28:29 -08:00
|
|
|
func (h *handler) saveEntry(w http.ResponseWriter, r *http.Request) {
|
2018-09-23 21:02:26 -07:00
|
|
|
entryID := request.RouteInt64Param(r, "entryID")
|
2018-11-11 11:28:29 -08:00
|
|
|
builder := h.store.NewEntryQueryBuilder(request.UserID(r))
|
2018-04-29 16:35:04 -07:00
|
|
|
builder.WithEntryID(entryID)
|
|
|
|
builder.WithoutStatus(model.EntryStatusRemoved)
|
|
|
|
|
|
|
|
entry, err := builder.GetEntry()
|
|
|
|
if err != nil {
|
2018-10-07 18:42:43 -07:00
|
|
|
json.ServerError(w, r, err)
|
2018-04-29 16:35:04 -07:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if entry == nil {
|
2018-10-07 18:42:43 -07:00
|
|
|
json.NotFound(w, r)
|
2018-04-29 16:35:04 -07:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-09-10 17:47:05 -07:00
|
|
|
userIntegrations, err := h.store.Integration(request.UserID(r))
|
2018-04-29 16:35:04 -07:00
|
|
|
if err != nil {
|
2018-10-07 18:42:43 -07:00
|
|
|
json.ServerError(w, r, err)
|
2018-04-29 16:35:04 -07:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-09-10 17:47:05 -07:00
|
|
|
go integration.SendEntry(entry, userIntegrations)
|
2018-04-29 16:35:04 -07:00
|
|
|
|
2018-10-07 18:42:43 -07:00
|
|
|
json.Created(w, r, map[string]string{"message": "saved"})
|
2018-04-29 16:35:04 -07:00
|
|
|
}
|