2017-06-10 02:19:31 +02:00

41 lines
787 B
Go

package profile
import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const maxPosts = 5
// Get ...
func Get(ctx *aero.Context) string {
nick := ctx.Get("nick")
viewUser, err := arn.GetUserByNick(nick)
if err != nil {
return ctx.Error(404, "User not found", err)
}
var user *arn.User
var threads []*arn.Thread
var animeList *arn.AnimeList
aero.Async(func() {
user = utils.GetUser(ctx)
}, func() {
animeList = viewUser.AnimeList()
}, func() {
threads = viewUser.Threads()
arn.SortThreadsByDate(threads)
if len(threads) > maxPosts {
threads = threads[:maxPosts]
}
})
return ctx.HTML(components.Profile(viewUser, user, animeList, threads))
}