aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1')
-rw-r--r--routers/api/v1/api.go2
-rw-r--r--routers/api/v1/org/team.go6
-rw-r--r--routers/api/v1/repo/fork.go2
-rw-r--r--routers/api/v1/repo/release.go2
-rw-r--r--routers/api/v1/repo/repo.go6
-rw-r--r--routers/api/v1/user/star.go7
-rw-r--r--routers/api/v1/user/watch.go6
7 files changed, 12 insertions, 19 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index 611a8f91de..ca4592c607 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -70,7 +70,7 @@ func repoAssignment() macaron.Handler {
if ctx.IsSigned && ctx.User.IsAdmin {
ctx.Repo.AccessMode = models.AccessModeOwner
} else {
- mode, err := models.AccessLevel(ctx.User, repo)
+ mode, err := models.AccessLevel(ctx.User.ID, repo)
if err != nil {
ctx.Error(500, "AccessLevel", err)
return
diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go
index f9d93399ae..dbd6ccc460 100644
--- a/routers/api/v1/org/team.go
+++ b/routers/api/v1/org/team.go
@@ -131,7 +131,7 @@ func GetTeamRepos(ctx *context.APIContext) {
}
repos := make([]*api.Repository, len(team.Repos))
for i, repo := range team.Repos {
- access, err := models.AccessLevel(ctx.User, repo)
+ access, err := models.AccessLevel(ctx.User.ID, repo)
if err != nil {
ctx.Error(500, "GetTeamRepos", err)
return
@@ -161,7 +161,7 @@ func AddTeamRepository(ctx *context.APIContext) {
if ctx.Written() {
return
}
- if access, err := models.AccessLevel(ctx.User, repo); err != nil {
+ if access, err := models.AccessLevel(ctx.User.ID, repo); err != nil {
ctx.Error(500, "AccessLevel", err)
return
} else if access < models.AccessModeAdmin {
@@ -181,7 +181,7 @@ func RemoveTeamRepository(ctx *context.APIContext) {
if ctx.Written() {
return
}
- if access, err := models.AccessLevel(ctx.User, repo); err != nil {
+ if access, err := models.AccessLevel(ctx.User.ID, repo); err != nil {
ctx.Error(500, "AccessLevel", err)
return
} else if access < models.AccessModeAdmin {
diff --git a/routers/api/v1/repo/fork.go b/routers/api/v1/repo/fork.go
index e8f57ace74..9c6da754ef 100644
--- a/routers/api/v1/repo/fork.go
+++ b/routers/api/v1/repo/fork.go
@@ -20,7 +20,7 @@ func ListForks(ctx *context.APIContext) {
}
apiForks := make([]*api.Repository, len(forks))
for i, fork := range forks {
- access, err := models.AccessLevel(ctx.User, fork)
+ access, err := models.AccessLevel(ctx.User.ID, 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 7dacb8018a..a367e55717 100644
--- a/routers/api/v1/repo/release.go
+++ b/routers/api/v1/repo/release.go
@@ -40,7 +40,7 @@ func ListReleases(ctx *context.APIContext) {
return
}
rels := make([]*api.Release, len(releases))
- access, err := models.AccessLevel(ctx.User, ctx.Repo.Repository)
+ access, err := models.AccessLevel(ctx.User.ID, ctx.Repo.Repository)
if err != nil {
ctx.Error(500, "AccessLevel", err)
return
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index a43246624e..317b0c57a1 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -64,7 +64,7 @@ func Search(ctx *context.APIContext) {
})
return
}
- accessMode, err := models.AccessLevel(ctx.User, repo)
+ accessMode, err := models.AccessLevel(ctx.User.ID, repo)
if err != nil {
ctx.JSON(500, map[string]interface{}{
"ok": false,
@@ -218,7 +218,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
// see https://github.com/gogits/go-gogs-client/wiki/Repositories#get
func Get(ctx *context.APIContext) {
repo := ctx.Repo.Repository
- access, err := models.AccessLevel(ctx.User, repo)
+ access, err := models.AccessLevel(ctx.User.ID, repo)
if err != nil {
ctx.Error(500, "GetRepository", err)
return
@@ -238,7 +238,7 @@ func GetByID(ctx *context.APIContext) {
return
}
- access, err := models.AccessLevel(ctx.User, repo)
+ access, err := models.AccessLevel(ctx.User.ID, repo)
if err != nil {
ctx.Error(500, "GetRepositoryByID", err)
return
diff --git a/routers/api/v1/user/star.go b/routers/api/v1/user/star.go
index 0937fd1903..47d3ed5079 100644
--- a/routers/api/v1/user/star.go
+++ b/routers/api/v1/user/star.go
@@ -18,13 +18,10 @@ func getStarredRepos(userID int64, private bool) ([]*api.Repository, error) {
if err != nil {
return nil, err
}
- user, err := models.GetUserByID(userID)
- if err != nil {
- return nil, err
- }
+
repos := make([]*api.Repository, len(starredRepos))
for i, starred := range starredRepos {
- access, err := models.AccessLevel(user, starred)
+ access, err := models.AccessLevel(userID, starred)
if err != nil {
return nil, err
}
diff --git a/routers/api/v1/user/watch.go b/routers/api/v1/user/watch.go
index 6a9ad670d0..2a94e219fe 100644
--- a/routers/api/v1/user/watch.go
+++ b/routers/api/v1/user/watch.go
@@ -31,14 +31,10 @@ func getWatchedRepos(userID int64, private bool) ([]*api.Repository, error) {
if err != nil {
return nil, err
}
- user, err := models.GetUserByID(userID)
- if err != nil {
- return nil, err
- }
repos := make([]*api.Repository, len(watchedRepos))
for i, watched := range watchedRepos {
- access, err := models.AccessLevel(user, watched)
+ access, err := models.AccessLevel(userID, watched)
if err != nil {
return nil, err
}