summaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-12-06 13:34:54 +0800
committerGitHub <noreply@github.com>2019-12-06 13:34:54 +0800
commite3081c667a44db469fac1e1de2d03b2d3106f100 (patch)
treeb2d0bbefd1f1aef55adf1570c8782949a34ad819 /routers/api
parent77730db25768036a12e16cef9839b9492218303f (diff)
downloadgitea-e3081c667a44db469fac1e1de2d03b2d3106f100.tar.gz
gitea-e3081c667a44db469fac1e1de2d03b2d3106f100.zip
Only show part of members on orgnization dashboard and add paging for orgnization members page (#9092)
* Only show part of members on orgnization dashboard and add paging for orgnization members page * fix test * fix typo
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/org/member.go31
1 files changed, 7 insertions, 24 deletions
diff --git a/routers/api/v1/org/member.go b/routers/api/v1/org/member.go
index be47b6963f..45519e5606 100644
--- a/routers/api/v1/org/member.go
+++ b/routers/api/v1/org/member.go
@@ -18,30 +18,13 @@ import (
// listMembers list an organization's members
func listMembers(ctx *context.APIContext, publicOnly bool) {
var members []*models.User
- if publicOnly {
- orgUsers, err := models.GetOrgUsersByOrgID(ctx.Org.Organization.ID)
- if err != nil {
- ctx.Error(500, "GetOrgUsersByOrgID", err)
- return
- }
-
- memberIDs := make([]int64, 0, len(orgUsers))
- for _, orgUser := range orgUsers {
- if orgUser.IsPublic {
- memberIDs = append(memberIDs, orgUser.UID)
- }
- }
-
- if members, err = models.GetUsersByIDs(memberIDs); err != nil {
- ctx.Error(500, "GetUsersByIDs", err)
- return
- }
- } else {
- if err := ctx.Org.Organization.GetMembers(); err != nil {
- ctx.Error(500, "GetMembers", err)
- return
- }
- members = ctx.Org.Organization.Members
+ members, _, err := models.FindOrgMembers(models.FindOrgMembersOpts{
+ OrgID: ctx.Org.Organization.ID,
+ PublicOnly: publicOnly,
+ })
+ if err != nil {
+ ctx.Error(500, "GetUsersByIDs", err)
+ return
}
apiMembers := make([]*api.User, len(members))