28 lines
602 B
Go
Raw Normal View History

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