Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 committed Oct 10, 2024
1 parent 340e8ea commit 4bcec1e
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions models/organization/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"code.gitea.io/gitea/modules/util"

"xorm.io/builder"
"xorm.io/xorm"
)

// ________ .__ __ .__
Expand Down Expand Up @@ -206,27 +205,12 @@ func (opts FindOrgMembersOpts) PublicOnly() bool {
return opts.Doer == nil || !opts.IsMember && !opts.Doer.IsAdmin
}

func (opts FindOrgMembersOpts) addTeamMatesOnlyFilter(ctx context.Context, sess *xorm.Session) error {
if opts.Doer != nil && opts.IsMember && opts.Doer.IsRestricted {
teamMates := builder.Select("DISTINCT team_user.uid").
From("team_user").
Where(builder.In("team_user.team_id", userTeamIDbuilder(opts.OrgID, opts.Doer.ID))).
And(builder.Eq{"team_user.org_id": opts.OrgID})

sess.In("org_user.uid", teamMates)
}
return nil
}

// CountOrgMembers counts the organization's members
func CountOrgMembers(ctx context.Context, opts *FindOrgMembersOpts) (int64, error) {
sess := db.GetEngine(ctx).Where("org_id=?", opts.OrgID)
if opts.PublicOnly() {
sess.And("is_public = ?", true)
}
if err := opts.addTeamMatesOnlyFilter(ctx, sess); err != nil {
return 0, err
}

return sess.Count(new(OrgUser))
}
Expand Down Expand Up @@ -551,9 +535,6 @@ func GetOrgUsersByOrgID(ctx context.Context, opts *FindOrgMembersOpts) ([]*OrgUs
if opts.PublicOnly() {
sess.And("is_public = ?", true)
}
if err := opts.addTeamMatesOnlyFilter(ctx, sess); err != nil {
return nil, err
}

if opts.ListOptions.PageSize > 0 {
sess = db.SetSessionPagination(sess, opts)
Expand Down

0 comments on commit 4bcec1e

Please sign in to comment.