26 lines
575 B
Go
Raw Normal View History

2018-04-25 19:12:47 +02:00
package post
import (
2017-06-28 00:16:45 +02:00
"net/http"
"github.com/aerogo/aero"
2019-06-03 18:32:43 +09:00
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/server/middleware"
)
2017-06-17 01:25:02 +02:00
// Get post.
2019-06-01 13:55:49 +09:00
func Get(ctx aero.Context) error {
id := ctx.Get("id")
2019-11-17 16:59:34 +09:00
user := arn.GetUserFromContext(ctx)
post, err := arn.GetPost(id)
if err != nil {
2017-06-28 00:16:45 +02:00
return ctx.Error(http.StatusNotFound, "Post not found", err)
}
2019-06-01 13:55:49 +09:00
customCtx := ctx.(*middleware.OpenGraphContext)
2019-06-05 16:18:04 +09:00
customCtx.OpenGraph = getOpenGraph(post)
2017-07-06 16:54:10 +02:00
return ctx.HTML(components.Post(post, user))
}