diff options
author | Ethan Koenig <ethantkoenig@gmail.com> | 2016-12-07 16:25:29 -0500 |
---|---|---|
committer | Kim "BKC" Carlbäcker <kim.carlbacker@gmail.com> | 2016-12-09 20:11:56 +0100 |
commit | 7b5b5178e1b8becd8df8cef0348e68173267a730 (patch) | |
tree | ef43da3b80a2fb98f3f0b9c849e2c3118e7cb9dc /routers/api/v1/repo/hook.go | |
parent | bab737bf02e1857356dddb0f17325b7d92faf987 (diff) | |
download | gitea-7b5b5178e1b8becd8df8cef0348e68173267a730.tar.gz gitea-7b5b5178e1b8becd8df8cef0348e68173267a730.zip |
Bug fix for edit-hook API endpoint
Diffstat (limited to 'routers/api/v1/repo/hook.go')
-rw-r--r-- | routers/api/v1/repo/hook.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/routers/api/v1/repo/hook.go b/routers/api/v1/repo/hook.go index 30e1fad363..1299f13923 100644 --- a/routers/api/v1/repo/hook.go +++ b/routers/api/v1/repo/hook.go @@ -102,7 +102,8 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) { // EditHook modify a hook of a repository // see https://github.com/gogits/go-gogs-client/wiki/Repositories#edit-a-hook func EditHook(ctx *context.APIContext, form api.EditHookOption) { - w, err := models.GetWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) + hookID := ctx.ParamsInt64(":id") + w, err := models.GetWebhookByRepoID(ctx.Repo.Repository.ID, hookID) if err != nil { if models.IsErrWebhookNotExist(err) { ctx.Status(404) @@ -165,7 +166,12 @@ func EditHook(ctx *context.APIContext, form api.EditHookOption) { return } - ctx.JSON(200, convert.ToHook(ctx.Repo.RepoLink, w)) + updated, err := models.GetWebhookByRepoID(ctx.Repo.Repository.ID, hookID) + if err != nil { + ctx.Error(500, "GetWebhookByRepoID", err) + return + } + ctx.JSON(200, convert.ToHook(ctx.Repo.RepoLink, updated)) } // DeleteHook delete a hook of a repository |