only return 400 errors

This commit is contained in:
Niko Abeler 2022-08-23 21:08:14 +02:00
parent 76633aaf89
commit cf367b6abd
2 changed files with 4 additions and 4 deletions

View File

@ -61,7 +61,7 @@ func userWebmentionHandler(repo *owl.Repository) func(http.ResponseWriter, *http
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
user, err := getUserFromRepo(repo, ps)
if err != nil {
w.WriteHeader(http.StatusNotFound)
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte("User not found"))
return
}
@ -105,14 +105,14 @@ func userWebmentionHandler(repo *owl.Repository) func(http.ResponseWriter, *http
parts := strings.Split(target[0], "/")
if len(parts) < 2 {
w.WriteHeader(http.StatusNotFound)
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte("Not found"))
return
}
postId := parts[len(parts)-2]
post, err := user.GetPost(postId)
if err != nil {
w.WriteHeader(http.StatusNotFound)
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte("Post not found"))
return
}

View File

@ -157,7 +157,7 @@ func TestValidationOfTarget(t *testing.T) {
t.Fatal(err)
}
assertStatus(t, rr, http.StatusNotFound)
assertStatus(t, rr, http.StatusBadRequest)
}
//