minor fix on API response
This commit is contained in:
parent
2b393f5b03
commit
1453e91f41
5 changed files with 13 additions and 16 deletions
|
@ -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++
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
// ToApiUser converts user to API format.
|
||||
|
@ -20,7 +19,9 @@ func ToApiUser(u *models.User) *api.User {
|
|||
return &api.User{
|
||||
ID: u.Id,
|
||||
UserName: u.Name,
|
||||
AvatarUrl: string(setting.Protocol) + u.AvatarLink(),
|
||||
FullName: u.FullName,
|
||||
Email: u.Email,
|
||||
AvatarUrl: u.AvatarLink(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue