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:
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user