Compare commits

..

No commits in common. "3addbb50de426f16695a9f16b7257938589b82b5" and "d4b51a6ad7f904c76b7455ac8dec6fa87b6353e4" have entirely different histories.

7 changed files with 18 additions and 19 deletions

View File

@ -25,7 +25,7 @@ import (
"regexp" "regexp"
"time" "time"
"github.com/gomodule/redigo/redis" "github.com/garyburd/redigo/redis"
) )
// TokenResponse is the information that we get back from the token endpoint of the user... // TokenResponse is the information that we get back from the token endpoint of the user...

View File

@ -33,7 +33,7 @@ import (
"p83.nl/go/ekster/pkg/util" "p83.nl/go/ekster/pkg/util"
"github.com/alecthomas/template" "github.com/alecthomas/template"
"github.com/gomodule/redigo/redis" "github.com/garyburd/redigo/redis"
"willnorris.com/go/microformats" "willnorris.com/go/microformats"
) )

View File

@ -30,7 +30,7 @@ import (
"p83.nl/go/ekster/pkg/util" "p83.nl/go/ekster/pkg/util"
"p83.nl/go/ekster/pkg/websub" "p83.nl/go/ekster/pkg/websub"
"github.com/gomodule/redigo/redis" "github.com/garyburd/redigo/redis"
) )
// LeaseSeconds is the default number of seconds we want the subscription to last // LeaseSeconds is the default number of seconds we want the subscription to last

View File

@ -27,8 +27,7 @@ import (
"time" "time"
"cloud.google.com/go/profiler" "cloud.google.com/go/profiler"
"github.com/gomodule/redigo/redis" "github.com/garyburd/redigo/redis"
"p83.nl/go/ekster/pkg/microsub" "p83.nl/go/ekster/pkg/microsub"
) )

View File

@ -36,7 +36,7 @@ import (
"p83.nl/go/ekster/pkg/fetch" "p83.nl/go/ekster/pkg/fetch"
"p83.nl/go/ekster/pkg/microsub" "p83.nl/go/ekster/pkg/microsub"
"github.com/gomodule/redigo/redis" "github.com/garyburd/redigo/redis"
"willnorris.com/go/microformats" "willnorris.com/go/microformats"
) )
@ -511,8 +511,6 @@ func (b *memoryBackend) Search(query string) ([]microsub.Feed, error) {
log.Printf("Error while fetching %s: %v\n", u, err) log.Printf("Error while fetching %s: %v\n", u, err)
continue continue
} }
defer resp.Body.Close()
fetchUrl, err := url.Parse(u) fetchUrl, err := url.Parse(u)
md := microformats.Parse(resp.Body, fetchUrl) md := microformats.Parse(resp.Body, fetchUrl)
if err != nil { if err != nil {
@ -569,7 +567,6 @@ func (b *memoryBackend) PreviewURL(previewURL string) (microsub.Timeline, error)
if err != nil { if err != nil {
return microsub.Timeline{}, fmt.Errorf("error while fetching %s: %v", previewURL, err) return microsub.Timeline{}, fmt.Errorf("error while fetching %s: %v", previewURL, err)
} }
defer resp.Body.Close()
items, err := fetch.FeedItems(&fetch2{}, previewURL, resp.Header.Get("content-type"), resp.Body) items, err := fetch.FeedItems(&fetch2{}, previewURL, resp.Header.Get("content-type"), resp.Body)
if err != nil { if err != nil {
return microsub.Timeline{}, fmt.Errorf("error while fetching %s: %v", previewURL, err) return microsub.Timeline{}, fmt.Errorf("error while fetching %s: %v", previewURL, err)

View File

@ -29,7 +29,7 @@ import (
"p83.nl/go/ekster/pkg/jf2" "p83.nl/go/ekster/pkg/jf2"
"p83.nl/go/ekster/pkg/microsub" "p83.nl/go/ekster/pkg/microsub"
"github.com/gomodule/redigo/redis" "github.com/garyburd/redigo/redis"
"willnorris.com/go/microformats" "willnorris.com/go/microformats"
) )

View File

@ -26,7 +26,7 @@ import (
"p83.nl/go/ekster/pkg/microsub" "p83.nl/go/ekster/pkg/microsub"
"github.com/gomodule/redigo/redis" "github.com/garyburd/redigo/redis"
) )
type microsubHandler struct { type microsubHandler struct {
@ -225,11 +225,18 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if method == "mark_read" || r.PostForm.Get("method") == "mark_read" { if method == "mark_read" || r.PostForm.Get("method") == "mark_read" {
values = r.Form values = r.Form
channel := values.Get("channel") channel := values.Get("channel")
var markAsRead []string
if uids, e := values["entry"]; e { if uids, e := values["entry"]; e {
markAsRead = uids err := h.Backend.MarkRead(channel, uids)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
} else if uids, e := values["entry[]"]; e { } else if uids, e := values["entry[]"]; e {
markAsRead = uids err := h.Backend.MarkRead(channel, uids)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
} else { } else {
uids := []string{} uids := []string{}
for k, v := range values { for k, v := range values {
@ -237,11 +244,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
uids = append(uids, v...) uids = append(uids, v...)
} }
} }
markAsRead = uids err := h.Backend.MarkRead(channel, uids)
}
if len(markAsRead) > 0 {
err := h.Backend.MarkRead(channel, markAsRead)
if err != nil { if err != nil {
http.Error(w, err.Error(), 500) http.Error(w, err.Error(), 500)
return return