mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 21:19:19 +00:00
fever api fixes
This commit is contained in:
parent
4f20f537c0
commit
e2d8ca3506
@ -205,8 +205,9 @@ func FeverFaviconsHandler(rw http.ResponseWriter, req *http.Request) {
|
|||||||
func FeverItemsHandler(rw http.ResponseWriter, req *http.Request) {
|
func FeverItemsHandler(rw http.ResponseWriter, req *http.Request) {
|
||||||
filter := storage.ItemFilter{}
|
filter := storage.ItemFilter{}
|
||||||
query := req.URL.Query()
|
query := req.URL.Query()
|
||||||
// TODO: must be switch case?
|
|
||||||
if _, ok := query["with_ids"]; ok {
|
switch {
|
||||||
|
case query.Get("with_ids") != "":
|
||||||
ids := make([]int64, 0)
|
ids := make([]int64, 0)
|
||||||
for _, idstr := range strings.Split(query.Get("with_ids"), ",") {
|
for _, idstr := range strings.Split(query.Get("with_ids"), ",") {
|
||||||
if idnum, err := strconv.ParseInt(idstr, 10, 64); err == nil {
|
if idnum, err := strconv.ParseInt(idstr, 10, 64); err == nil {
|
||||||
@ -214,16 +215,12 @@ func FeverItemsHandler(rw http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
filter.IDs = &ids
|
filter.IDs = &ids
|
||||||
}
|
case query.Get("since_id") != "":
|
||||||
|
|
||||||
if _, ok := query["since_id"]; ok {
|
|
||||||
idstr := query.Get("since_id")
|
idstr := query.Get("since_id")
|
||||||
if idnum, err := strconv.ParseInt(idstr, 10, 64); err == nil {
|
if idnum, err := strconv.ParseInt(idstr, 10, 64); err == nil {
|
||||||
filter.SinceID = &idnum
|
filter.SinceID = &idnum
|
||||||
}
|
}
|
||||||
}
|
case query.Get("max_id") != "":
|
||||||
|
|
||||||
if _, ok := query["max_id"]; ok {
|
|
||||||
idstr := query.Get("max_id")
|
idstr := query.Get("max_id")
|
||||||
if idnum, err := strconv.ParseInt(idstr, 10, 64); err == nil {
|
if idnum, err := strconv.ParseInt(idstr, 10, 64); err == nil {
|
||||||
filter.MaxID = &idnum
|
filter.MaxID = &idnum
|
||||||
@ -278,7 +275,7 @@ func FeverLinksHandler(rw http.ResponseWriter, req *http.Request) {
|
|||||||
func FeverMarkHandler(rw http.ResponseWriter, req *http.Request) {
|
func FeverMarkHandler(rw http.ResponseWriter, req *http.Request) {
|
||||||
query := req.URL.Query()
|
query := req.URL.Query()
|
||||||
|
|
||||||
id, err := strconv.ParseInt(query.Get("id"), 10, 0)
|
id, err := strconv.ParseInt(query.Get("id"), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
handler(req).log.Print("invalid id:", err)
|
handler(req).log.Print("invalid id:", err)
|
||||||
return
|
return
|
||||||
@ -302,11 +299,11 @@ func FeverMarkHandler(rw http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
db(req).UpdateItemStatus(id, status)
|
db(req).UpdateItemStatus(id, status)
|
||||||
case "feed":
|
case "feed":
|
||||||
x, _ := strconv.ParseInt(query.Get("before"), 10, 0)
|
x, _ := strconv.ParseInt(query.Get("before"), 10, 64)
|
||||||
before := time.Unix(x, 0)
|
before := time.Unix(x, 0)
|
||||||
db(req).MarkItemsRead(storage.MarkFilter{FeedID: &id, Before: &before})
|
db(req).MarkItemsRead(storage.MarkFilter{FeedID: &id, Before: &before})
|
||||||
case "group":
|
case "group":
|
||||||
x, _ := strconv.ParseInt(query.Get("before"), 10, 0)
|
x, _ := strconv.ParseInt(query.Get("before"), 10, 64)
|
||||||
before := time.Unix(x, 0)
|
before := time.Unix(x, 0)
|
||||||
db(req).MarkItemsRead(storage.MarkFilter{FolderID: &id, Before: &before})
|
db(req).MarkItemsRead(storage.MarkFilter{FolderID: &id, Before: &before})
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user