Browse Source

Fix ActivityStreams, only serve AS on desired paths

master
Jan-Lukas Else 3 weeks ago
parent
commit
eb5675f0b0
2 changed files with 10 additions and 14 deletions
  1. +6
    -14
      http.go
  2. +4
    -0
      posts.go

+ 6
- 14
http.go View File

@ -112,14 +112,7 @@ var (
captchaHandler http.Handler
micropubRouter *chi.Mux
indieAuthRouter *chi.Mux
webmentionsRouter *chi.Mux
notificationsRouter *chi.Mux
activitypubRouter *chi.Mux
editorRouter *chi.Mux
commentsRouter *chi.Mux
searchRouter *chi.Mux
micropubRouter, indieAuthRouter, webmentionsRouter, notificationsRouter, activitypubRouter, editorRouter, commentsRouter, searchRouter *chi.Mux
setBlogMiddlewares = map[string]func(http.Handler) http.Handler{}
sectionMiddlewares = map[string]func(http.Handler) http.Handler{}
@ -274,7 +267,6 @@ func buildDynamicRouter() (*chi.Mux, error) {
r.Use(checkIsLogin)
r.Use(checkIsCaptcha)
r.Use(checkLoggedIn)
r.Use(checkActivityStreamsRequest)
// Logout
r.With(authMiddleware).Get("/login", serveLogin)
@ -308,7 +300,7 @@ func buildDynamicRouter() (*chi.Mux, error) {
}
r.Group(func(r chi.Router) {
r.Use(privateModeHandler...)
r.Use(cacheMiddleware)
r.Use(checkActivityStreamsRequest, cacheMiddleware)
for _, path := range pp {
r.Get(path, servePost)
}
@ -465,10 +457,10 @@ func buildDynamicRouter() (*chi.Mux, error) {
if !blogConfig.PostAsHome {
r.Group(func(r chi.Router) {
r.Use(privateModeHandler...)
r.Use(cacheMiddleware, sbm)
r.Get(blogConfig.Path, serveHome)
r.Get(blogConfig.Path+feedPath, serveHome)
r.Get(blogPath+paginationPath, serveHome)
r.Use(sbm)
r.With(checkActivityStreamsRequest, cacheMiddleware).Get(blogConfig.Path, serveHome)
r.With(cacheMiddleware).Get(blogConfig.Path+feedPath, serveHome)
r.With(cacheMiddleware).Get(blogPath+paginationPath, serveHome)
})
}


+ 4
- 0
posts.go View File

@ -53,6 +53,10 @@ func servePost(w http.ResponseWriter, r *http.Request) {
return
}
if asRequest, ok := r.Context().Value(asRequestKey).(bool); ok && asRequest {
if r.URL.Path == blogPath(p.Blog) {
appConfig.Blogs[p.Blog].serveActivityStreams(p.Blog, w, r)
return
}
p.serveActivityStreams(w)
return
}


Loading…
Cancel
Save