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 f1a766d544..5da87fa7df 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 39ce896cd6..cf4c328ebb 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 a5e70de548..535a49d766 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,