diff options
Diffstat (limited to 'routers/api/v1/repo')
-rw-r--r-- | routers/api/v1/repo/fork.go | 3 | ||||
-rw-r--r-- | routers/api/v1/repo/release.go | 8 | ||||
-rw-r--r-- | routers/api/v1/repo/repo.go | 8 | ||||
-rw-r--r-- | routers/api/v1/repo/status.go | 7 |
4 files changed, 5 insertions, 21 deletions
diff --git a/routers/api/v1/repo/fork.go b/routers/api/v1/repo/fork.go index 44b79a6fef..25464dbd78 100644 --- a/routers/api/v1/repo/fork.go +++ b/routers/api/v1/repo/fork.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/routers/api/v1/utils" ) // ListForks list a repository's forks @@ -29,7 +30,7 @@ func ListForks(ctx *context.APIContext) { } apiForks := make([]*api.Repository, len(forks)) for i, fork := range forks { - access, err := models.AccessLevel(ctx.User.ID, fork) + access, err := models.AccessLevel(utils.UserID(ctx), fork) if err != nil { ctx.Error(500, "AccessLevel", err) return diff --git a/routers/api/v1/repo/release.go b/routers/api/v1/repo/release.go index ed5b8f4f78..302be8dbab 100644 --- a/routers/api/v1/repo/release.go +++ b/routers/api/v1/repo/release.go @@ -34,14 +34,8 @@ func GetRelease(ctx *context.APIContext) { // ListReleases list a repository's releases func ListReleases(ctx *context.APIContext) { - access, err := models.AccessLevel(ctx.User.ID, ctx.Repo.Repository) - if err != nil { - ctx.Error(500, "AccessLevel", err) - return - } - releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, models.FindReleasesOptions{ - IncludeDrafts: access >= models.AccessModeWrite, + IncludeDrafts: ctx.Repo.AccessMode >= models.AccessModeWrite, }, 1, 2147483647) if err != nil { ctx.Error(500, "GetReleasesByRepoID", err) diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 7fb828ddbc..178f1005e5 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -267,13 +267,7 @@ func Get(ctx *context.APIContext) { // 200: Repository // 500: error - repo := ctx.Repo.Repository - access, err := models.AccessLevel(ctx.User.ID, repo) - if err != nil { - ctx.Error(500, "GetRepository", err) - return - } - ctx.JSON(200, repo.APIFormat(access)) + ctx.JSON(200, ctx.Repo.Repository.APIFormat(ctx.Repo.AccessMode)) } // GetByID returns a single Repository diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go index d9b101df05..e4cc20a50b 100644 --- a/routers/api/v1/repo/status.go +++ b/routers/api/v1/repo/status.go @@ -103,15 +103,10 @@ func GetCombinedCommitStatus(ctx *context.APIContext) { return } - acl, err := models.AccessLevel(ctx.User.ID, repo) - if err != nil { - ctx.Error(500, "AccessLevel", fmt.Errorf("AccessLevel[%d, %s]: %v", ctx.User.ID, repo.FullName(), err)) - return - } retStatus := &combinedCommitStatus{ SHA: sha, TotalCount: len(statuses), - Repo: repo.APIFormat(acl), + Repo: repo.APIFormat(ctx.Repo.AccessMode), URL: "", } |