Skip to content

Commit 7129e28

Browse files
committed
Adjust the logic
1 parent f950175 commit 7129e28

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

models/repo_list.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,22 @@ func userOrgPublicRepoCond(userID int64) builder.Cond {
302302
)
303303
}
304304

305+
func userOrgPublicRepoCondPrivate(userID int64) builder.Cond {
306+
return builder.And(
307+
builder.Eq{"`repository`.is_private": false},
308+
builder.In("`repository`.owner_id",
309+
builder.Select("`org_user`.org_id").
310+
From("org_user").
311+
Join("INNER", "`user`", "`user`.id = `org_user`.org_id").
312+
Where(builder.Eq{
313+
"`org_user`.uid": userID,
314+
"`user`.type": UserTypeOrganization,
315+
"`user`.visibility": structs.VisibleTypePrivate,
316+
}),
317+
),
318+
)
319+
}
320+
305321
func userOrgPublicUnitRepoCond(userID, orgID int64) builder.Cond {
306322
return userOrgPublicRepoCond(userID).
307323
And(builder.Eq{"`repository`.owner_id": orgID})
@@ -364,7 +380,7 @@ func SearchRepositoryCondition(opts *SearchRepoOptions) builder.Cond {
364380
// B. We are in a team for
365381
userOrgTeamRepoCond("`repository`.id", opts.OwnerID),
366382
// C. Public repositories in organizations that we are member of
367-
userOrgPublicRepoCond(opts.OwnerID),
383+
userOrgPublicRepoCondPrivate(opts.OwnerID),
368384
),
369385
)
370386
if !opts.Private {

0 commit comments

Comments
 (0)