Forum activity shown in user profiles

This commit is contained in:
2017-06-08 14:46:38 +02:00
parent 4a6e4378ce
commit 4f7ef694c8
13 changed files with 100 additions and 44 deletions

View File

@ -4,16 +4,28 @@ 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")
user, err := arn.GetUserByNick(nick)
viewUser, err := arn.GetUserByNick(nick)
user := utils.GetUser(ctx)
if err != nil {
return ctx.Error(404, "User not found", err)
}
return ctx.HTML(components.Profile(user, nil))
threads := viewUser.Threads()
arn.SortThreadsByDate(threads)
if len(threads) > maxPosts {
threads = threads[:maxPosts]
}
return ctx.HTML(components.Profile(viewUser, user, threads))
}