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 // Verify request
requestActor, requestKey, requestActorStatus, err := apVerifySignature(r) requestActor, requestKey, requestActorStatus, err := apVerifySignature(r)
if err != nil { 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 return
} }
if requestActorStatus != 0 { if requestActorStatus != 0 {
@ -98,7 +99,7 @@ func apHandleInbox(w http.ResponseWriter, r *http.Request) {
u.Fragment = "" u.Fragment = ""
u.RawFragment = "" u.RawFragment = ""
apRemoveFollower(blogName, u.String()) apRemoveFollower(blogName, u.String())
w.WriteHeader(http.StatusAccepted) w.WriteHeader(http.StatusOK)
return return
} }
} }
@ -179,8 +180,8 @@ func apHandleInbox(w http.ResponseWriter, r *http.Request) {
} }
} }
} }
// Return 201 // Return 200
w.WriteHeader(http.StatusCreated) w.WriteHeader(http.StatusOK)
} }
func apVerifySignature(r *http.Request) (*asPerson, string, int, error) { func apVerifySignature(r *http.Request) (*asPerson, string, int, error) {

View File

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