Fixed mistakes

This commit is contained in:
FM1337
2017-06-22 12:03:43 -03:00
parent ad7bc381ac
commit f6e5b6da08
4 changed files with 22 additions and 21 deletions

View File

@ -8,32 +8,31 @@ import (
"github.com/animenotifier/notify.moe/components"
)
const postLimit = 10
// GetPostsbyUser shows all forum posts of a particular user.
func GetPostsByUser(ctx *aero.Context) string {
postLimit := 10
nick := ctx.Get("nick")
user, err := arn.GetUserByNick(nick)
var postables []arn.Postable
if err != nil {
return ctx.Error(http.StatusNotFound, "User not found", err)
}
posts := user.Posts()
arn.SortPostsLatestLast(posts)
var postables []arn.Postable
if len(posts) >= postLimit {
postables = make([]arn.Postable, postLimit, postLimit)
} else {
postables = make([]arn.Postable, len(posts), len(posts))
posts = posts[:postLimit]
}
postables = make([]arn.Postable, len(posts), len(posts))
for i, post := range posts {
if i == postLimit {
break
}
postables[i] = arn.ToPostable(post)
}
return ctx.HTML(components.PostableList(postables))