46 lines
899 B
Go
Raw Normal View History

2018-10-31 05:27:48 +00:00
package activity
import (
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const maxActivitiesPerPage = 40
// Get activity page.
func Get(ctx *aero.Context) string {
user := utils.GetUser(ctx)
// posts := arn.AllPosts()
// arn.SortPostsLatestFirst(posts)
// posts := arn.FilterPosts(func(post *arn.Post) bool {
// return post.
// })
entries := arn.FilterEditLogEntries(func(entry *arn.EditLogEntry) bool {
2018-11-05 04:19:42 +00:00
if entry.Action != "create" {
return false
}
obj := entry.Object()
if obj == nil {
return false
}
_, isPostable := obj.(arn.Postable)
return isPostable
2018-10-31 05:27:48 +00:00
})
arn.SortEditLogEntriesLatestFirst(entries)
if len(entries) > maxActivitiesPerPage {
entries = entries[:maxActivitiesPerPage]
}
return ctx.HTML(components.ActivityFeed(entries, user))
}