summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-08-19 20:08:57 +0800
committerUnknwon <u@gogs.io>2015-08-19 20:08:57 +0800
commit1453e91f419e52fc74e3ec51b47a080a27a33342 (patch)
treee8bb9e381999b6a8a09685af003ed7580da2a116 /routers/api/v1/repo.go
parent2b393f5b039db177a58be03f1c5c746eac501686 (diff)
downloadgitea-1453e91f419e52fc74e3ec51b47a080a27a33342.tar.gz
gitea-1453e91f419e52fc74e3ec51b47a080a27a33342.zip
minor fix on API response
Diffstat (limited to 'routers/api/v1/repo.go')
-rw-r--r--routers/api/v1/repo.go18
1 files changed, 6 insertions, 12 deletions
diff --git a/routers/api/v1/repo.go b/routers/api/v1/repo.go
index c6dabfcb86..3f5394172a 100644
--- a/routers/api/v1/repo.go
+++ b/routers/api/v1/repo.go
@@ -120,7 +120,7 @@ func createRepo(ctx *middleware.Context, owner *models.User, opt api.CreateRepoO
return
}
- ctx.JSON(200, ToApiRepository(owner, repo, api.Permission{true, true, true}))
+ ctx.JSON(201, ToApiRepository(owner, repo, api.Permission{true, true, true}))
}
// POST /user/repos
@@ -254,17 +254,11 @@ func ListMyRepos(ctx *middleware.Context) {
i := numOwnRepos
for repo, access := range accessibleRepos {
- if err = repo.GetOwner(); err != nil {
- ctx.JSON(500, &base.ApiJsonErr{"GetOwner: " + err.Error(), base.DOC_URL})
- return
- }
-
- repos[i] = ToApiRepository(repo.Owner, repo, api.Permission{false, access >= models.ACCESS_MODE_WRITE, true})
-
- // FIXME: cache result to reduce DB query?
- if repo.Owner.IsOrganization() && repo.Owner.IsOwnedBy(ctx.User.Id) {
- repos[i].Permissions.Admin = true
- }
+ repos[i] = ToApiRepository(repo.Owner, repo, api.Permission{
+ Admin: access >= models.ACCESS_MODE_ADMIN,
+ Push: access >= models.ACCESS_MODE_WRITE,
+ Pull: true,
+ })
i++
}