28 lines
602 B
Go
Raw Normal View History

2018-04-25 18:59:23 +02:00
package thread
2016-11-19 23:54:31 +09:00
import (
2017-06-26 23:41:16 +02:00
"net/http"
2017-06-26 15:17:53 +02:00
2016-11-19 23:54:31 +09:00
"github.com/aerogo/aero"
2019-06-03 18:32:43 +09:00
"github.com/animenotifier/notify.moe/arn"
2016-11-19 23:54:31 +09:00
"github.com/animenotifier/notify.moe/components"
2019-06-01 13:55:49 +09:00
"github.com/animenotifier/notify.moe/middleware"
2016-11-19 23:54:31 +09:00
)
2017-06-17 01:25:02 +02:00
// Get thread.
2019-06-01 13:55:49 +09:00
func Get(ctx aero.Context) error {
2016-11-19 23:54:31 +09:00
id := ctx.Get("id")
2019-11-17 16:59:34 +09:00
user := arn.GetUserFromContext(ctx)
2016-11-19 23:54:31 +09:00
2017-06-26 23:41:16 +02:00
// Fetch thread
thread, err := arn.GetThread(id)
2016-11-19 23:54:31 +09:00
if err != nil {
2017-06-26 23:41:16 +02:00
return ctx.Error(http.StatusNotFound, "Thread not found", err)
2016-11-19 23:54:31 +09:00
}
2019-06-01 13:55:49 +09:00
customCtx := ctx.(*middleware.OpenGraphContext)
2019-06-05 16:18:04 +09:00
customCtx.OpenGraph = getOpenGraph(thread)
2018-11-05 19:05:36 +09:00
return ctx.HTML(components.Thread(thread, user))
2016-11-19 23:54:31 +09:00
}