diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-05-11 18:09:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-11 12:09:36 +0200 |
commit | cbd45471b1100bffcd2f18719b56a5da5468756b (patch) | |
tree | 11fcb818fd4e9d7b6bdb97d1b5bfbe2ed3df5747 /routers/api/v1/user | |
parent | 8e8e936adacea873013b89d534f60207e67f2b05 (diff) | |
download | gitea-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/user')
-rw-r--r-- | routers/api/v1/user/repo.go | 5 | ||||
-rw-r--r-- | routers/api/v1/user/star.go | 4 | ||||
-rw-r--r-- | routers/api/v1/user/watch.go | 4 |
3 files changed, 7 insertions, 6 deletions
diff --git a/routers/api/v1/user/repo.go b/routers/api/v1/user/repo.go index 0231c8ccbc..05cecf508b 100644 --- a/routers/api/v1/user/repo.go +++ b/routers/api/v1/user/repo.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/perm" + access_model "code.gitea.io/gitea/models/perm/access" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/convert" @@ -38,7 +39,7 @@ func listUserRepos(ctx *context.APIContext, u *user_model.User, private bool) { apiRepos := make([]*api.Repository, 0, len(repos)) for i := range repos { - access, err := models.AccessLevel(ctx.Doer, repos[i]) + access, err := access_model.AccessLevel(ctx.Doer, repos[i]) if err != nil { ctx.Error(http.StatusInternalServerError, "AccessLevel", err) return @@ -123,7 +124,7 @@ func ListMyRepos(ctx *context.APIContext) { ctx.Error(http.StatusInternalServerError, "GetOwner", err) return } - accessMode, err := models.AccessLevel(ctx.Doer, repo) + accessMode, err := access_model.AccessLevel(ctx.Doer, repo) if err != nil { ctx.Error(http.StatusInternalServerError, "AccessLevel", err) } diff --git a/routers/api/v1/user/star.go b/routers/api/v1/user/star.go index cdbc35471b..d2e4f36cd7 100644 --- a/routers/api/v1/user/star.go +++ b/routers/api/v1/user/star.go @@ -8,8 +8,8 @@ package user import ( "net/http" - "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" + access_model "code.gitea.io/gitea/models/perm/access" repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" @@ -28,7 +28,7 @@ func getStarredRepos(user *user_model.User, private bool, listOptions db.ListOpt repos := make([]*api.Repository, len(starredRepos)) for i, starred := range starredRepos { - access, err := models.AccessLevel(user, starred) + access, err := access_model.AccessLevel(user, starred) if err != nil { return nil, err } diff --git a/routers/api/v1/user/watch.go b/routers/api/v1/user/watch.go index e7c6837cb8..652ef3f8a6 100644 --- a/routers/api/v1/user/watch.go +++ b/routers/api/v1/user/watch.go @@ -7,8 +7,8 @@ package user import ( "net/http" - "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" + access_model "code.gitea.io/gitea/models/perm/access" repo_model "code.gitea.io/gitea/models/repo" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/context" @@ -26,7 +26,7 @@ func getWatchedRepos(user *user_model.User, private bool, listOptions db.ListOpt repos := make([]*api.Repository, len(watchedRepos)) for i, watched := range watchedRepos { - access, err := models.AccessLevel(user, watched) + access, err := access_model.AccessLevel(user, watched) if err != nil { return nil, 0, err } |