aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo/pull.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-05-11 18:09:36 +0800
committerGitHub <noreply@github.com>2022-05-11 12:09:36 +0200
commitcbd45471b1100bffcd2f18719b56a5da5468756b (patch)
tree11fcb818fd4e9d7b6bdb97d1b5bfbe2ed3df5747 /routers/api/v1/repo/pull.go
parent8e8e936adacea873013b89d534f60207e67f2b05 (diff)
downloadgitea-cbd45471b1100bffcd2f18719b56a5da5468756b.tar.gz
gitea-cbd45471b1100bffcd2f18719b56a5da5468756b.zip
Move access and repo permission to models/perm/access (#19350)
* Move access and repo permission to models/perm/access * Remove unnecessary code
Diffstat (limited to 'routers/api/v1/repo/pull.go')
-rw-r--r--routers/api/v1/repo/pull.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index f95bc6b16b..a01efda1bc 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -15,6 +15,7 @@ import (
"code.gitea.io/gitea/models"
issues_model "code.gitea.io/gitea/models/issues"
+ access_model "code.gitea.io/gitea/models/perm/access"
pull_model "code.gitea.io/gitea/models/pull"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unit"
@@ -402,7 +403,7 @@ func CreatePullRequest(ctx *context.APIContext) {
return
}
- valid, err := models.CanBeAssigned(assignee, repo, true)
+ valid, err := access_model.CanBeAssigned(ctx, assignee, repo, true)
if err != nil {
ctx.Error(http.StatusInternalServerError, "canBeAssigned", err)
return
@@ -983,7 +984,7 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
}
// user should have permission to read baseRepo's codes and pulls, NOT headRepo's
- permBase, err := models.GetUserRepoPermission(ctx, baseRepo, ctx.Doer)
+ permBase, err := access_model.GetUserRepoPermission(ctx, baseRepo, ctx.Doer)
if err != nil {
headGitRepo.Close()
ctx.Error(http.StatusInternalServerError, "GetUserRepoPermission", err)
@@ -1002,7 +1003,7 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
}
// user should have permission to read headrepo's codes
- permHead, err := models.GetUserRepoPermission(ctx, headRepo, ctx.Doer)
+ permHead, err := access_model.GetUserRepoPermission(ctx, headRepo, ctx.Doer)
if err != nil {
headGitRepo.Close()
ctx.Error(http.StatusInternalServerError, "GetUserRepoPermission", err)
@@ -1197,7 +1198,7 @@ func CancelScheduledAutoMerge(ctx *context.APIContext) {
}
if ctx.Doer.ID != autoMerge.DoerID {
- allowed, err := models.IsUserRepoAdminCtx(ctx, ctx.Repo.Repository, ctx.Doer)
+ allowed, err := access_model.IsUserRepoAdminCtx(ctx, ctx.Repo.Repository, ctx.Doer)
if err != nil {
ctx.InternalServerError(err)
return