Backport #24823 by @sonjek
Should resolve first point of the issue
https://github.com/go-gitea/gitea/issues/24574
Co-authored-by: Yevhen Pavlov <yevhen.pavlov.ua@gmail.com>
(cherry picked from commit f29c52a169
)
This commit is contained in:
parent
5dc29fdeb1
commit
16bcceeff7
1 changed files with 7 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
||||||
package admin
|
package admin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models/webhook"
|
"code.gitea.io/gitea/models/webhook"
|
||||||
|
@ -74,7 +75,11 @@ func GetHook(ctx *context.APIContext) {
|
||||||
hookID := ctx.ParamsInt64(":id")
|
hookID := ctx.ParamsInt64(":id")
|
||||||
hook, err := webhook.GetSystemOrDefaultWebhook(ctx, hookID)
|
hook, err := webhook.GetSystemOrDefaultWebhook(ctx, hookID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, util.ErrNotExist) {
|
||||||
|
ctx.NotFound()
|
||||||
|
} else {
|
||||||
ctx.Error(http.StatusInternalServerError, "GetSystemOrDefaultWebhook", err)
|
ctx.Error(http.StatusInternalServerError, "GetSystemOrDefaultWebhook", err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
h, err := webhook_service.ToHook("/admin/", hook)
|
h, err := webhook_service.ToHook("/admin/", hook)
|
||||||
|
@ -163,7 +168,7 @@ func DeleteHook(ctx *context.APIContext) {
|
||||||
|
|
||||||
hookID := ctx.ParamsInt64(":id")
|
hookID := ctx.ParamsInt64(":id")
|
||||||
if err := webhook.DeleteDefaultSystemWebhook(ctx, hookID); err != nil {
|
if err := webhook.DeleteDefaultSystemWebhook(ctx, hookID); err != nil {
|
||||||
if webhook.IsErrWebhookNotExist(err) {
|
if errors.Is(err, util.ErrNotExist) {
|
||||||
ctx.NotFound()
|
ctx.NotFound()
|
||||||
} else {
|
} else {
|
||||||
ctx.Error(http.StatusInternalServerError, "DeleteDefaultSystemWebhook", err)
|
ctx.Error(http.StatusInternalServerError, "DeleteDefaultSystemWebhook", err)
|
||||||
|
|
Loading…
Reference in a new issue