Fixed mistakes
This commit is contained in:
@ -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))
|
||||
|
Reference in New Issue
Block a user