Fix order of before and after

This commit is contained in:
Peter Stuifzand 2018-05-12 14:37:29 +02:00
parent ada6c45a0a
commit e2b577eef9
4 changed files with 16 additions and 5 deletions

View File

@ -142,13 +142,24 @@ func performCommands(sub microsub.Microsub, commands []string) {
}
}
if len(commands) == 3 && commands[1] == "timeline" {
if len(commands) >= 3 && commands[1] == "timeline" {
channel := commands[2]
timeline := sub.TimelineGet("", "", channel)
var timeline microsub.Timeline
if len(commands) == 5 && commands[3] == "-after" {
timeline = sub.TimelineGet("", commands[4], channel)
} else if len(commands) == 5 && commands[3] == "-before" {
timeline = sub.TimelineGet(commands[4], "", channel)
} else {
timeline = sub.TimelineGet("", "", channel)
}
for _, item := range timeline.Items {
showItem(&item)
}
fmt.Printf("Before: %s, After: %s\n", timeline.Paging.Before, timeline.Paging.After)
}
if len(commands) == 3 && commands[1] == "search" {

View File

@ -187,7 +187,7 @@ func (h *microsubHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
"channels": channels,
})
} else if action == "timeline" {
timeline := h.Backend.TimelineGet(values.Get("after"), values.Get("before"), values.Get("channel"))
timeline := h.Backend.TimelineGet(values.Get("before"), values.Get("after"), values.Get("channel"))
jw := json.NewEncoder(w)
w.Header().Add("Content-Type", "application/json")
jw.SetIndent("", " ")

View File

@ -368,7 +368,7 @@ func (b *memoryBackend) run() {
}()
}
func (b *memoryBackend) TimelineGet(after, before, channel string) microsub.Timeline {
func (b *memoryBackend) TimelineGet(before, after, channel string) microsub.Timeline {
conn := pool.Get()
defer conn.Close()

View File

@ -56,7 +56,7 @@ func (b *NullBackend) ChannelsDelete(uid string) {
}
// TimelineGet gets no timeline
func (b *NullBackend) TimelineGet(after, before, channel string) microsub.Timeline {
func (b *NullBackend) TimelineGet(before, after, channel string) microsub.Timeline {
return microsub.Timeline{
Paging: microsub.Pagination{},
Items: []microsub.Item{},