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

Add bookmarks

This commit is contained in:
Frédéric Guillot 2017-12-22 11:33:01 -08:00
parent b153fa8b3c
commit 9868f900e9
31 changed files with 688 additions and 78 deletions

View file

@ -12,8 +12,8 @@ import (
"github.com/miniflux/miniflux/server/core"
)
// GetEntry is the API handler to get a single feed entry.
func (c *Controller) GetEntry(ctx *core.Context, request *core.Request, response *core.Response) {
// GetFeedEntry is the API handler to get a single feed entry.
func (c *Controller) GetFeedEntry(ctx *core.Context, request *core.Request, response *core.Response) {
userID := ctx.UserID()
feedID, err := request.IntegerParam("feedID")
if err != nil {
@ -45,6 +45,32 @@ func (c *Controller) GetEntry(ctx *core.Context, request *core.Request, response
response.JSON().Standard(entry)
}
// GetEntry is the API handler to get a single entry.
func (c *Controller) GetEntry(ctx *core.Context, request *core.Request, response *core.Response) {
userID := ctx.UserID()
entryID, err := request.IntegerParam("entryID")
if err != nil {
response.JSON().BadRequest(err)
return
}
builder := c.store.GetEntryQueryBuilder(userID, ctx.UserTimezone())
builder.WithEntryID(entryID)
entry, err := builder.GetEntry()
if err != nil {
response.JSON().ServerError(errors.New("Unable to fetch this entry from the database"))
return
}
if entry == nil {
response.JSON().NotFound(errors.New("Entry not found"))
return
}
response.JSON().Standard(entry)
}
// GetFeedEntries is the API handler to get all feed entries.
func (c *Controller) GetFeedEntries(ctx *core.Context, request *core.Request, response *core.Response) {
userID := ctx.UserID()
@ -179,3 +205,20 @@ func (c *Controller) SetEntryStatus(ctx *core.Context, request *core.Request, re
response.JSON().NoContent()
}
// ToggleBookmark is the API handler to toggle bookmark status.
func (c *Controller) ToggleBookmark(ctx *core.Context, request *core.Request, response *core.Response) {
userID := ctx.UserID()
entryID, err := request.IntegerParam("entryID")
if err != nil {
response.JSON().BadRequest(err)
return
}
if err := c.store.ToggleBookmark(userID, entryID); err != nil {
response.JSON().ServerError(errors.New("Unable to toggle bookmark value"))
return
}
response.JSON().NoContent()
}