Plugin groups (#30320)
* add new pluginapi methods * SAML login hook * set ReAddRemovedMembers to true for plugin groups * change to DoLogin signature for SAML
Этот коммит содержится в:
@@ -5862,7 +5862,7 @@ func (c *Client4) GetGroupsAssociatedToChannelsByTeam(ctx context.Context, teamI
|
||||
// GetGroups retrieves Mattermost Groups
|
||||
func (c *Client4) GetGroups(ctx context.Context, opts GroupSearchOpts) ([]*Group, *Response, error) {
|
||||
path := fmt.Sprintf(
|
||||
"%s?include_member_count=%v¬_associated_to_team=%v¬_associated_to_channel=%v&filter_allow_reference=%v&q=%v&filter_parent_team_permitted=%v&group_source=%v&include_channel_member_count=%v&include_timezones=%v&include_archived=%v&filter_archived=%v",
|
||||
"%s?include_member_count=%v¬_associated_to_team=%v¬_associated_to_channel=%v&filter_allow_reference=%v&q=%v&filter_parent_team_permitted=%v&group_source=%v&include_channel_member_count=%v&include_timezones=%v&include_archived=%v&filter_archived=%v&only_syncable_sources=%v",
|
||||
c.groupsRoute(),
|
||||
opts.IncludeMemberCount,
|
||||
opts.NotAssociatedToTeam,
|
||||
@@ -5875,6 +5875,7 @@ func (c *Client4) GetGroups(ctx context.Context, opts GroupSearchOpts) ([]*Group
|
||||
opts.IncludeTimezones,
|
||||
opts.IncludeArchived,
|
||||
opts.FilterArchived,
|
||||
opts.OnlySyncableSources,
|
||||
)
|
||||
if opts.Since > 0 {
|
||||
path = fmt.Sprintf("%s&since=%v", path, opts.Since)
|
||||
|
||||
@@ -6,12 +6,16 @@ package model
|
||||
import (
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
GroupSourceLdap GroupSource = "ldap"
|
||||
GroupSourceCustom GroupSource = "custom"
|
||||
|
||||
// plugin groups must prefix their source with this
|
||||
GroupSourcePluginPrefix GroupSource = "plugin_"
|
||||
|
||||
GroupNameMaxLength = 64
|
||||
GroupSourceMaxLength = 64
|
||||
GroupDisplayNameMaxLength = 128
|
||||
@@ -21,15 +25,6 @@ const (
|
||||
|
||||
type GroupSource string
|
||||
|
||||
var allGroupSources = []GroupSource{
|
||||
GroupSourceLdap,
|
||||
GroupSourceCustom,
|
||||
}
|
||||
|
||||
var groupSourcesRequiringRemoteID = []GroupSource{
|
||||
GroupSourceLdap,
|
||||
}
|
||||
|
||||
type Group struct {
|
||||
Id string `json:"id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
@@ -157,6 +152,9 @@ type GroupSearchOpts struct {
|
||||
|
||||
// Only return archived groups
|
||||
FilterArchived bool
|
||||
|
||||
// OnlySyncableSources filters the groups to only those that are syncable
|
||||
OnlySyncableSources bool
|
||||
}
|
||||
|
||||
type GetGroupOpts struct {
|
||||
@@ -214,12 +212,12 @@ func (group *Group) IsValidForCreate() *AppError {
|
||||
}
|
||||
|
||||
isValidSource := false
|
||||
for _, groupSource := range allGroupSources {
|
||||
if group.Source == groupSource {
|
||||
isValidSource = true
|
||||
break
|
||||
}
|
||||
if group.Source == GroupSourceLdap ||
|
||||
group.Source == GroupSourceCustom ||
|
||||
strings.HasPrefix(string(group.Source), string(GroupSourcePluginPrefix)) {
|
||||
isValidSource = true
|
||||
}
|
||||
|
||||
if !isValidSource {
|
||||
return NewAppError("Group.IsValidForCreate", "model.group.source.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
@@ -232,12 +230,19 @@ func (group *Group) IsValidForCreate() *AppError {
|
||||
}
|
||||
|
||||
func (group *Group) requiresRemoteId() bool {
|
||||
for _, groupSource := range groupSourcesRequiringRemoteID {
|
||||
if groupSource == group.Source {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return group.Source == GroupSourceLdap || strings.HasPrefix(string(group.Source), string(GroupSourcePluginPrefix))
|
||||
}
|
||||
|
||||
func GetSyncableGroupSources() []GroupSource {
|
||||
return []GroupSource{GroupSourceLdap}
|
||||
}
|
||||
|
||||
func GetSyncableGroupSourcePrefixes() []GroupSource {
|
||||
return []GroupSource{GroupSourcePluginPrefix}
|
||||
}
|
||||
|
||||
func (group *Group) IsSyncable() bool {
|
||||
return group.Source == GroupSourceLdap || strings.HasPrefix(string(group.Source), string(GroupSourcePluginPrefix))
|
||||
}
|
||||
|
||||
func (group *Group) IsValidForUpdate() *AppError {
|
||||
|
||||
Ссылка в новой задаче
Block a user