1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

models/webhook: restrict deletion to be explicitly with repo and org ID

This commit is contained in:
Unknwon
2016-07-17 08:33:59 +08:00
parent 5ff2dfb23e
commit 60110adc06
7 changed files with 55 additions and 48 deletions

View File

@@ -96,15 +96,6 @@ func CreateHook(ctx *context.APIContext, form api.CreateHookOption) {
ctx.JSON(201, convert.ToHook(ctx.Repo.RepoLink, w))
}
func DeleteHook(ctx *context.APIContext) {
if err := models.DeleteWebhook(ctx.ParamsInt64(":id")); err != nil {
ctx.Error(500, "DeleteWebhook", err)
return
}
ctx.Status(204)
}
// 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"))
@@ -171,3 +162,12 @@ func EditHook(ctx *context.APIContext, form api.EditHookOption) {
ctx.JSON(200, convert.ToHook(ctx.Repo.RepoLink, w))
}
func DeleteHook(ctx *context.APIContext) {
if err := models.DeleteWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")); err != nil {
ctx.Error(500, "DeleteWebhookByRepoID", err)
return
}
ctx.Status(204)
}