From 73394f435c4a15b9d2ef5449213254f12fb34e1d Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Mon, 30 Aug 2021 20:00:59 +0200 Subject: [PATCH] [API] List limited and private orgs if authentificated (#16866) * fix bug #16785 and similar * code format * CI.restart() --- routers/api/v1/admin/org.go | 1 + routers/api/v1/org/org.go | 1 + routers/api/v1/user/user.go | 6 ++---- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go index f1a766d54..5da87fa7d 100644 --- a/routers/api/v1/admin/org.go +++ b/routers/api/v1/admin/org.go @@ -105,6 +105,7 @@ func GetAllOrgs(ctx *context.APIContext) { listOptions := utils.GetListOptions(ctx) users, maxResults, err := models.SearchUsers(&models.SearchUserOptions{ + Actor: ctx.User, Type: models.UserTypeOrganization, OrderBy: models.SearchOrderByAlphabetically, ListOptions: listOptions, diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go index 39ce896cd..cf4c328eb 100644 --- a/routers/api/v1/org/org.go +++ b/routers/api/v1/org/org.go @@ -128,6 +128,7 @@ func GetAll(ctx *context.APIContext) { listOptions := utils.GetListOptions(ctx) publicOrgs, maxResults, err := models.SearchUsers(&models.SearchUserOptions{ + Actor: ctx.User, ListOptions: listOptions, Type: models.UserTypeOrganization, OrderBy: models.SearchOrderByAlphabetically, diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go index a5e70de54..535a49d76 100644 --- a/routers/api/v1/user/user.go +++ b/routers/api/v1/user/user.go @@ -54,15 +54,13 @@ func Search(ctx *context.APIContext) { listOptions := utils.GetListOptions(ctx) - opts := &models.SearchUserOptions{ + users, maxResults, err := models.SearchUsers(&models.SearchUserOptions{ Actor: ctx.User, Keyword: ctx.FormTrim("q"), UID: ctx.FormInt64("uid"), Type: models.UserTypeIndividual, ListOptions: listOptions, - } - - users, maxResults, err := models.SearchUsers(opts) + }) if err != nil { ctx.JSON(http.StatusInternalServerError, map[string]interface{}{ "ok": false,