Move webhook into models/webhook/ (#17579)

This commit is contained in:
Lunny Xiao 2021-11-10 13:13:16 +08:00 committed by GitHub
parent edbaa5d3f0
commit 33fca2b537
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 770 additions and 717 deletions

View file

@ -7,7 +7,7 @@ package org
import (
"net/http"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/webhook"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/convert"
api "code.gitea.io/gitea/modules/structs"
@ -40,18 +40,18 @@ func ListHooks(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/HookList"
opts := &models.ListWebhookOptions{
opts := &webhook.ListWebhookOptions{
ListOptions: utils.GetListOptions(ctx),
OrgID: ctx.Org.Organization.ID,
}
count, err := models.CountWebhooksByOpts(opts)
count, err := webhook.CountWebhooksByOpts(opts)
if err != nil {
ctx.InternalServerError(err)
return
}
orgHooks, err := models.ListWebhooksByOpts(opts)
orgHooks, err := webhook.ListWebhooksByOpts(opts)
if err != nil {
ctx.InternalServerError(err)
return
@ -191,8 +191,8 @@ func DeleteHook(ctx *context.APIContext) {
org := ctx.Org.Organization
hookID := ctx.ParamsInt64(":id")
if err := models.DeleteWebhookByOrgID(org.ID, hookID); err != nil {
if models.IsErrWebhookNotExist(err) {
if err := webhook.DeleteWebhookByOrgID(org.ID, hookID); err != nil {
if webhook.IsErrWebhookNotExist(err) {
ctx.NotFound()
} else {
ctx.Error(http.StatusInternalServerError, "DeleteWebhookByOrgID", err)