mirror of https://github.com/jlelse/GoBlog
Change response codes for activitypub inbox
This commit is contained in:
parent
7acdca8b92
commit
10b71871ec
|
@ -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) {
|
||||
|
|
4
http.go
4
http.go
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue