Skip to content

Commit

Permalink
Slight simplification of accessibleRepositoryCondition (#10875)
Browse files Browse the repository at this point in the history
* Slight simplification of accessibleRepositoryCondition

Signed-off-by: Andrew Thornton <[email protected]>
  • Loading branch information
zeripath committed Mar 29, 2020
1 parent ad40264 commit 209045f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions models/repo_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,12 @@ func accessibleRepositoryCondition(user *User) builder.Cond {
// 1. Be able to see all non-private repositories that either:
cond = cond.Or(builder.And(
builder.Eq{"`repository`.is_private": false},
builder.Or(
// A. Aren't in organisations __OR__
builder.NotIn("`repository`.owner_id", builder.Select("id").From("`user`").Where(builder.Eq{"type": UserTypeOrganization})),
// B. Isn't a private organisation. Limited is OK as long as we're logged in.
builder.NotIn("`repository`.owner_id", builder.Select("id").From("`user`").Where(builder.In("visibility", orgVisibilityLimit))))))
// 2. Aren't in an private organisation or limited organisation if we're not logged in
builder.NotIn("`repository`.owner_id", builder.Select("id").From("`user`").Where(
builder.And(
builder.Eq{"type": UserTypeOrganization},
builder.In("visibility", orgVisibilityLimit)),
))))
}

if user != nil {
Expand Down

0 comments on commit 209045f

Please sign in to comment.