Change response codes for activitypub inbox

This commit is contained in:
Jan-Lukas Else 2020-11-13 21:29:09 +01:00
parent 7acdca8b92
commit 10b71871ec
2 changed files with 7 additions and 6 deletions

View File

@ -88,7 +88,8 @@ func apHandleInbox(w http.ResponseWriter, r *http.Request) {
// Verify request
requestActor, requestKey, requestActorStatus, err := apVerifySignature(r)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
// Send 401 because signature could not be verified
http.Error(w, err.Error(), http.StatusUnauthorized)
return
}
if requestActorStatus != 0 {
@ -98,7 +99,7 @@ func apHandleInbox(w http.ResponseWriter, r *http.Request) {
u.Fragment = ""
u.RawFragment = ""
apRemoveFollower(blogName, u.String())
w.WriteHeader(http.StatusAccepted)
w.WriteHeader(http.StatusOK)
return
}
}
@ -179,8 +180,8 @@ func apHandleInbox(w http.ResponseWriter, r *http.Request) {
}
}
}
// Return 201
w.WriteHeader(http.StatusCreated)
// Return 200
w.WriteHeader(http.StatusOK)
}
func apVerifySignature(r *http.Request) (*asPerson, string, int, error) {

View File

@ -112,8 +112,8 @@ func buildHandler() (http.Handler, error) {
// Micropub
r.Route(micropubPath, func(mpRouter chi.Router) {
mpRouter.Use(middleware.NoCache, checkIndieAuth)
mpRouter.Get("/", serveMicropubQuery)
mpRouter.Use(checkIndieAuth)
mpRouter.With(middleware.NoCache).Get("/", serveMicropubQuery)
mpRouter.Post("/", serveMicropubPost)
if appConfig.Micropub.MediaStorage != nil {
mpRouter.Post(micropubMediaSubPath, serveMicropubMedia)