fix: show membership of limited orgs

- Include organisations with visibility of limited if the visitor is signed in.
- Resolves forgejo/forgejo#8093
- Added unit test.
This commit is contained in:
Gusted 2025-06-06 19:33:26 +02:00
parent 82e4ccc223
commit b68f923592
No known key found for this signature in database
GPG key ID: FD821B732837125F
4 changed files with 29 additions and 3 deletions

View file

@ -26,6 +26,7 @@ type SearchOrganizationsOptions struct {
type FindOrgOptions struct {
db.ListOptions
UserID int64
IncludeLimited bool
IncludePrivate bool
}
@ -43,7 +44,11 @@ func (opts FindOrgOptions) ToConds() builder.Cond {
cond = cond.And(builder.In("`user`.`id`", queryUserOrgIDs(opts.UserID, opts.IncludePrivate)))
}
if !opts.IncludePrivate {
cond = cond.And(builder.Eq{"`user`.visibility": structs.VisibleTypePublic})
if !opts.IncludeLimited {
cond = cond.And(builder.Eq{"`user`.visibility": structs.VisibleTypePublic})
} else {
cond = cond.And(builder.In("`user`.visibility", structs.VisibleTypePublic, structs.VisibleTypeLimited))
}
}
return cond
}