36 lines
697 B
Go
Raw Normal View History

2018-03-09 18:04:06 +00:00
package editlog
import (
"net/http"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/utils"
)
2018-03-10 00:20:54 +00:00
const maxEntries = 120
2018-03-09 18:04:06 +00:00
// Get edit log.
func Get(ctx *aero.Context) string {
user := utils.GetUser(ctx)
if user == nil || (user.Role != "editor" && user.Role != "admin") {
return ctx.Error(http.StatusUnauthorized, "Not authorized", nil)
}
entries := arn.AllEditLogEntries()
// Sort by creation date
arn.SortEditLogEntriesLatestFirst(entries)
2018-03-09 18:04:06 +00:00
// Limit results
2018-03-09 18:04:06 +00:00
if len(entries) > maxEntries {
entries = entries[:maxEntries]
}
return ctx.HTML(components.EditLogPage(entries, user))
2018-03-09 18:04:06 +00:00
}