diff options
author | Unknwon <u@gogs.io> | 2016-03-11 15:33:12 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-03-11 15:33:12 -0500 |
commit | 2bf8494332592b3c57f9a12a26b9abd356fb3f15 (patch) | |
tree | e46c61ba30018ebbafcda6b97b36d3ffece3cfb0 /routers/api/v1/repo/repo.go | |
parent | df2bdf7ea36ad0729e0326ca799d8896d7f96946 (diff) | |
download | gitea-2bf8494332592b3c57f9a12a26b9abd356fb3f15.tar.gz gitea-2bf8494332592b3c57f9a12a26b9abd356fb3f15.zip |
#13 finish user and repository search
Both are possible on explore and admin panel
Diffstat (limited to 'routers/api/v1/repo/repo.go')
-rw-r--r-- | routers/api/v1/repo/repo.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index fc7a9cd442..e3d8368010 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -21,21 +21,21 @@ import ( // https://github.com/gogits/go-gogs-client/wiki/Repositories#search-repositories func Search(ctx *context.Context) { - opt := models.SearchOption{ - Keyword: path.Base(ctx.Query("q")), - Uid: com.StrTo(ctx.Query("uid")).MustInt64(), - Limit: com.StrTo(ctx.Query("limit")).MustInt(), + opts := &models.SearchRepoOptions{ + Keyword: path.Base(ctx.Query("q")), + OwnerID: com.StrTo(ctx.Query("uid")).MustInt64(), + PageSize: com.StrTo(ctx.Query("limit")).MustInt(), } - if opt.Limit == 0 { - opt.Limit = 10 + if opts.PageSize == 0 { + opts.PageSize = 10 } // Check visibility. - if ctx.IsSigned && opt.Uid > 0 { - if ctx.User.Id == opt.Uid { - opt.Private = true + if ctx.IsSigned && opts.OwnerID > 0 { + if ctx.User.Id == opts.OwnerID { + opts.Private = true } else { - u, err := models.GetUserByID(opt.Uid) + u, err := models.GetUserByID(opts.OwnerID) if err != nil { ctx.JSON(500, map[string]interface{}{ "ok": false, @@ -44,13 +44,13 @@ func Search(ctx *context.Context) { return } if u.IsOrganization() && u.IsOwnedBy(ctx.User.Id) { - opt.Private = true + opts.Private = true } // FIXME: how about collaborators? } } - repos, err := models.SearchRepositoryByName(opt) + repos, _, err := models.SearchRepositoryByName(opts) if err != nil { ctx.JSON(500, map[string]interface{}{ "ok": false, |