Possible fix the webhook API creation (#13960)

* Possible fix the webhook API creation

* Fix api create webhook bug
This commit is contained in:
Lunny Xiao 2020-12-12 23:33:19 +08:00 committed by GitHub
parent 6074e13c8d
commit 9f100a45c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View file

@ -6,6 +6,7 @@ package utils
import (
"encoding/json"
"fmt"
"net/http"
"strings"
@ -53,7 +54,7 @@ func GetRepoHook(ctx *context.APIContext, repoID, hookID int64) (*models.Webhook
// write the appropriate error to `ctx`. Return whether the form is valid
func CheckCreateHookOption(ctx *context.APIContext, form *api.CreateHookOption) bool {
if !webhook.IsValidHookTaskType(form.Type) {
ctx.Error(http.StatusUnprocessableEntity, "", "Invalid hook type")
ctx.Error(http.StatusUnprocessableEntity, "", fmt.Sprintf("Invalid hook type: %s", form.Type))
return false
}
for _, name := range []string{"url", "content_type"} {