32 lines
713 B
Go
Raw Normal View History

2017-10-18 21:17:54 +00:00
package group
import (
"net/http"
"github.com/aerogo/aero"
2019-06-03 09:32:43 +00:00
"github.com/animenotifier/notify.moe/arn"
2017-10-18 21:17:54 +00:00
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/server/middleware"
2017-10-18 21:17:54 +00:00
)
2018-11-21 09:12:29 +00:00
// Members shows the group members.
2019-06-01 04:55:49 +00:00
func Members(ctx aero.Context) error {
2019-11-17 07:59:34 +00:00
user := arn.GetUserFromContext(ctx)
2017-10-18 21:17:54 +00: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 09:12:29 +00:00
var member *arn.GroupMember
if user != nil {
member = group.FindMember(user.ID)
}
2019-06-01 04:55:49 +00:00
customCtx := ctx.(*middleware.OpenGraphContext)
2019-06-05 07:18:04 +00:00
customCtx.OpenGraph = getOpenGraph(group)
2018-11-21 09:12:29 +00:00
return ctx.HTML(components.GroupMembers(group, member, user))
2017-10-18 21:17:54 +00:00
}