mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-12488: Accepts parameters to search and filter LDAP groups. (#10418)
This commit is contained in:
12
api4/ldap.go
12
api4/ldap.go
@@ -68,7 +68,17 @@ func getLdapGroups(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
groups, total, err := c.App.GetAllLdapGroupsPage(c.Params.Page, c.Params.PerPage)
|
||||
opts := model.GroupSearchOpts{
|
||||
Q: c.Params.Q,
|
||||
}
|
||||
if c.Params.IsLinked != nil {
|
||||
opts.IsLinked = c.Params.IsLinked
|
||||
}
|
||||
if c.Params.IsConfigured != nil {
|
||||
opts.IsConfigured = c.Params.IsConfigured
|
||||
}
|
||||
|
||||
groups, total, err := c.App.GetAllLdapGroupsPage(c.Params.Page, c.Params.PerPage, opts)
|
||||
if err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
|
||||
@@ -61,13 +61,13 @@ func (a *App) GetLdapGroup(ldapGroupID string) (*model.Group, *model.AppError) {
|
||||
|
||||
// GetAllLdapGroupsPage retrieves all LDAP groups under the configured base DN using the default or configured group
|
||||
// filter.
|
||||
func (a *App) GetAllLdapGroupsPage(page int, perPage int) ([]*model.Group, int, *model.AppError) {
|
||||
func (a *App) GetAllLdapGroupsPage(page int, perPage int, opts model.GroupSearchOpts) ([]*model.Group, int, *model.AppError) {
|
||||
var groups []*model.Group
|
||||
var total int
|
||||
|
||||
if a.Ldap != nil {
|
||||
var err *model.AppError
|
||||
groups, total, err = a.Ldap.GetAllGroupsPage(page, perPage)
|
||||
groups, total, err = a.Ldap.GetAllGroupsPage(page, perPage, opts)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
@@ -19,6 +19,6 @@ type LdapInterface interface {
|
||||
GetAllLdapUsers() ([]*model.User, *model.AppError)
|
||||
MigrateIDAttribute(toAttribute string) error
|
||||
GetGroup(groupUID string) (*model.Group, *model.AppError)
|
||||
GetAllGroupsPage(page int, perPage int) ([]*model.Group, int, *model.AppError)
|
||||
GetAllGroupsPage(page int, perPage int, opts model.GroupSearchOpts) ([]*model.Group, int, *model.AppError)
|
||||
FirstLoginSync(userID, userAuthService, userAuthData string) *model.AppError
|
||||
}
|
||||
|
||||
@@ -48,6 +48,12 @@ type GroupPatch struct {
|
||||
Description *string `json:"description"`
|
||||
}
|
||||
|
||||
type GroupSearchOpts struct {
|
||||
Q string
|
||||
IsLinked *bool
|
||||
IsConfigured *bool
|
||||
}
|
||||
|
||||
func (group *Group) Patch(patch *GroupPatch) {
|
||||
if patch.Name != nil {
|
||||
group.Name = *patch.Name
|
||||
|
||||
@@ -59,6 +59,9 @@ type Params struct {
|
||||
SyncableId string
|
||||
SyncableType model.GroupSyncableType
|
||||
BotUserId string
|
||||
Q string
|
||||
IsLinked *bool
|
||||
IsConfigured *bool
|
||||
}
|
||||
|
||||
func ParamsFromRequest(r *http.Request) *Params {
|
||||
@@ -232,5 +235,15 @@ func ParamsFromRequest(r *http.Request) *Params {
|
||||
params.BotUserId = val
|
||||
}
|
||||
|
||||
params.Q = query.Get("q")
|
||||
|
||||
if val, err := strconv.ParseBool(query.Get("is_linked")); err == nil {
|
||||
params.IsLinked = &val
|
||||
}
|
||||
|
||||
if val, err := strconv.ParseBool(query.Get("is_configured")); err == nil {
|
||||
params.IsConfigured = &val
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user