summaryrefslogtreecommitdiffstats
path: root/models/repo_list.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-01-05 19:48:47 +0100
committerzeripath <art27@cantab.net>2020-01-05 18:48:47 +0000
commit133ae18b61c5d3bdfc7670b8320abe84dd96cbe2 (patch)
treef0578979a35ff329499b83888aa6f9e5278cb9c3 /models/repo_list.go
parent7e4f490482014fa52d15902b5aa20952461c64f4 (diff)
downloadgitea-133ae18b61c5d3bdfc7670b8320abe84dd96cbe2.tar.gz
gitea-133ae18b61c5d3bdfc7670b8320abe84dd96cbe2.zip
[BugFix] Hide public repos owned by private orgs (#9609)
* Restrict AllPublic to actually public repos. * Add new parameter to add in AllLimited Repos
Diffstat (limited to 'models/repo_list.go')
-rw-r--r--models/repo_list.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/models/repo_list.go b/models/repo_list.go
index 34fac8b055..7b48834dba 100644
--- a/models/repo_list.go
+++ b/models/repo_list.go
@@ -121,7 +121,8 @@ type SearchRepoOptions struct {
StarredByID int64
Page int
IsProfile bool
- AllPublic bool // Include also all public repositories
+ AllPublic bool // Include also all public repositories of users and public organisations
+ AllLimited bool // Include also all public repositories of limited organisations
PageSize int // Can be smaller than or equal to setting.ExplorePagingNum
// None -> include collaborative AND non-collaborative
// True -> include just collaborative
@@ -228,7 +229,11 @@ func SearchRepository(opts *SearchRepoOptions) (RepositoryList, int64, error) {
}
if opts.AllPublic {
- accessCond = accessCond.Or(builder.Eq{"is_private": false})
+ accessCond = accessCond.Or(builder.Eq{"is_private": false}.And(builder.In("owner_id", builder.Select("`user`.id").From("`user`").Where(builder.Eq{"`user`.visibility": structs.VisibleTypePublic}))))
+ }
+
+ if opts.AllLimited {
+ accessCond = accessCond.Or(builder.Eq{"is_private": false}.And(builder.In("owner_id", builder.Select("`user`.id").From("`user`").Where(builder.Eq{"`user`.visibility": structs.VisibleTypeLimited}))))
}
cond = cond.And(accessCond)