diff options
author | 6543 <6543@obermui.de> | 2020-01-12 16:43:44 +0100 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2020-01-12 23:43:44 +0800 |
commit | 10055bd2b1d18d3ccbec78cbc213e459ddb75804 (patch) | |
tree | 0c3aacafab3f852a0509c4dcd2055aa93e36c0c3 /models | |
parent | 497e15fdc28518ab03e2f1114fb112b8c0630e18 (diff) | |
download | gitea-10055bd2b1d18d3ccbec78cbc213e459ddb75804.tar.gz gitea-10055bd2b1d18d3ccbec78cbc213e459ddb75804.zip |
[API] add GET /orgs endpoint (#9560)
* introduce `GET /orgs`
* add TEST
* show also other VisibleType's
* update description
* refactor a lot
* SearchUserOptions by default return only public
Diffstat (limited to 'models')
-rw-r--r-- | models/user.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/models/user.go b/models/user.go index 9ddd262aed..dc8ae7e0f8 100644 --- a/models/user.go +++ b/models/user.go @@ -1469,7 +1469,7 @@ type SearchUserOptions struct { UID int64 OrderBy SearchOrderBy Page int - Private bool // Include private orgs in search + Visible []structs.VisibleType OwnerID int64 // id of user for visibility calculation PageSize int // Can be smaller than or equal to setting.UI.ExplorePagingNum IsActive util.OptionalBool @@ -1492,8 +1492,9 @@ func (opts *SearchUserOptions) toConds() builder.Cond { cond = cond.And(keywordCond) } - if !opts.Private { - // user not logged in and so they won't be allowed to see non-public orgs + if len(opts.Visible) > 0 { + cond = cond.And(builder.In("visibility", opts.Visible)) + } else { cond = cond.And(builder.In("visibility", structs.VisibleTypePublic)) } |