30 lines
598 B
Go
Raw Normal View History

2016-11-19 14:54:31 +00:00
package threads
import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
)
// Get ...
func Get(ctx *aero.Context) string {
id := ctx.Get("id")
thread, err := arn.GetThread(id)
if err != nil {
2016-11-23 05:26:59 +00:00
return ctx.Error(404, "Thread not found", err)
2016-11-19 14:54:31 +00:00
}
replies, filterErr := arn.FilterPosts(func(post *arn.Post) bool {
return post.ThreadID == thread.ID
})
2016-12-06 03:36:31 +00:00
arn.SortPostsLatestLast(replies)
2016-11-19 14:54:31 +00:00
if filterErr != nil {
2016-11-23 05:26:59 +00:00
return ctx.Error(500, "Error fetching thread replies", err)
2016-11-19 14:54:31 +00:00
}
return ctx.HTML(components.Thread(thread, replies))
}