summaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2022-05-08 15:46:34 +0200
committerGitHub <noreply@github.com>2022-05-08 15:46:34 +0200
commit6a969681cd862bf153fa7921485278be1e8a092a (patch)
treef9a23ee85652c0ee179f215b23d928058176ae6c /routers/api
parent4344a6410788f30848e5153f6356dcdd0774bebc (diff)
downloadgitea-6a969681cd862bf153fa7921485278be1e8a092a.tar.gz
gitea-6a969681cd862bf153fa7921485278be1e8a092a.zip
Delete related PullAutoMerge and ReviewState on User/Repo Deletion (#19649)
* delete pullautomerges on repo/user deletion * delete reviewstates on repo/user deletion * optimize automerhe code * add index to reviewstate
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/notify/threads.go3
-rw-r--r--routers/api/v1/repo/issue_tracked_time.go5
-rw-r--r--routers/api/v1/repo/pull.go2
3 files changed, 6 insertions, 4 deletions
diff --git a/routers/api/v1/notify/threads.go b/routers/api/v1/notify/threads.go
index fe89304dc8..4effd6b3e0 100644
--- a/routers/api/v1/notify/threads.go
+++ b/routers/api/v1/notify/threads.go
@@ -9,6 +9,7 @@ import (
"net/http"
"code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/convert"
)
@@ -102,7 +103,7 @@ func ReadThread(ctx *context.APIContext) {
func getThread(ctx *context.APIContext) *models.Notification {
n, err := models.GetNotificationByID(ctx.ParamsInt64(":id"))
if err != nil {
- if models.IsErrNotExist(err) {
+ if db.IsErrNotExist(err) {
ctx.Error(http.StatusNotFound, "GetNotificationByID", err)
} else {
ctx.InternalServerError(err)
diff --git a/routers/api/v1/repo/issue_tracked_time.go b/routers/api/v1/repo/issue_tracked_time.go
index e42dc60a94..8ccad87838 100644
--- a/routers/api/v1/repo/issue_tracked_time.go
+++ b/routers/api/v1/repo/issue_tracked_time.go
@@ -10,6 +10,7 @@ import (
"time"
"code.gitea.io/gitea/models"
+ "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/unit"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/context"
@@ -281,7 +282,7 @@ func ResetIssueTime(ctx *context.APIContext) {
err = models.DeleteIssueUserTimes(issue, ctx.Doer)
if err != nil {
- if models.IsErrNotExist(err) {
+ if db.IsErrNotExist(err) {
ctx.Error(http.StatusNotFound, "DeleteIssueUserTimes", err)
} else {
ctx.Error(http.StatusInternalServerError, "DeleteIssueUserTimes", err)
@@ -352,7 +353,7 @@ func DeleteTime(ctx *context.APIContext) {
time, err := models.GetTrackedTimeByID(ctx.ParamsInt64(":id"))
if err != nil {
- if models.IsErrNotExist(err) {
+ if db.IsErrNotExist(err) {
ctx.NotFound(err)
return
}
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index ecf96ea0c2..f95bc6b16b 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -1208,7 +1208,7 @@ func CancelScheduledAutoMerge(ctx *context.APIContext) {
}
}
- if err := pull_model.RemoveScheduledAutoMerge(ctx, ctx.Doer, pull.ID, true); err != nil {
+ if err := automerge.RemoveScheduledAutoMerge(ctx, ctx.Doer, pull); err != nil {
ctx.InternalServerError(err)
} else {
ctx.Status(http.StatusNoContent)