33 lines
742 B
Go
Raw Normal View History

2017-10-18 23:17:54 +02:00
package group
import (
"net/http"
"github.com/aerogo/aero"
2019-06-03 18:32:43 +09:00
"github.com/animenotifier/notify.moe/arn"
2017-10-18 23:17:54 +02:00
"github.com/animenotifier/notify.moe/components"
2019-06-01 13:55:49 +09:00
"github.com/animenotifier/notify.moe/middleware"
2018-03-07 00:36:04 +01:00
"github.com/animenotifier/notify.moe/utils"
2017-10-18 23:17:54 +02:00
)
2018-11-21 18:12:29 +09:00
// Info shows the group information page.
2019-06-01 13:55:49 +09:00
func Info(ctx aero.Context) error {
2018-03-07 00:36:04 +01:00
user := utils.GetUser(ctx)
2017-10-18 23:17:54 +02:00
id := ctx.Get("id")
group, err := arn.GetGroup(id)
if err != nil {
return ctx.Error(http.StatusNotFound, "Group not found", err)
}
2018-11-21 18:12:29 +09:00
var member *arn.GroupMember
if user != nil {
member = group.FindMember(user.ID)
}
2019-06-01 13:55:49 +09:00
customCtx := ctx.(*middleware.OpenGraphContext)
2019-06-05 16:18:04 +09:00
customCtx.OpenGraph = getOpenGraph(group)
2018-11-21 18:12:29 +09:00
return ctx.HTML(components.GroupInfo(group, member, user))
2017-10-18 23:17:54 +02:00
}