[MM-63772] Add LDAP setting to re-add removed members (#30787)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
5021fc72c6
Коммит
c2d08b7540
@@ -563,10 +563,10 @@ func (a *App) DeleteGroupSyncable(groupID string, syncableID string, syncableTyp
|
||||
// based on the groups configurations. The returned list can be optionally scoped to a single given team.
|
||||
//
|
||||
// Typically since will be the last successful group sync time.
|
||||
// If includeRemovedMembers is true, then team members who left or were removed from the team will
|
||||
// If reAddRemovedMembers is true, then team members who left or were removed from the team will
|
||||
// be included; otherwise, they will be excluded.
|
||||
func (a *App) TeamMembersToAdd(since int64, teamID *string, includeRemovedMembers bool) ([]*model.UserTeamIDPair, *model.AppError) {
|
||||
userTeams, err := a.Srv().Store().Group().TeamMembersToAdd(since, teamID, includeRemovedMembers)
|
||||
func (a *App) TeamMembersToAdd(since int64, teamID *string, reAddRemovedMembers bool) ([]*model.UserTeamIDPair, *model.AppError) {
|
||||
userTeams, err := a.Srv().Store().Group().TeamMembersToAdd(since, teamID, reAddRemovedMembers)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("TeamMembersToAdd", "app.select_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
@@ -578,10 +578,10 @@ func (a *App) TeamMembersToAdd(since int64, teamID *string, includeRemovedMember
|
||||
// based on the groups configurations. The returned list can be optionally scoped to a single given channel.
|
||||
//
|
||||
// Typically since will be the last successful group sync time.
|
||||
// If includeRemovedMembers is true, then channel members who left or were removed from the channel will
|
||||
// If reAddRemovedMembers is true, then channel members who left or were removed from the channel will
|
||||
// be included; otherwise, they will be excluded.
|
||||
func (a *App) ChannelMembersToAdd(since int64, channelID *string, includeRemovedMembers bool) ([]*model.UserChannelIDPair, *model.AppError) {
|
||||
userChannels, err := a.Srv().Store().Group().ChannelMembersToAdd(since, channelID, includeRemovedMembers)
|
||||
func (a *App) ChannelMembersToAdd(since int64, channelID *string, reAddRemovedMembers bool) ([]*model.UserChannelIDPair, *model.AppError) {
|
||||
userChannels, err := a.Srv().Store().Group().ChannelMembersToAdd(since, channelID, reAddRemovedMembers)
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("ChannelMembersToAdd", "app.select_error", nil, "", http.StatusInternalServerError).Wrap(err)
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ import (
|
||||
)
|
||||
|
||||
// SyncLdap starts an LDAP sync job.
|
||||
// If includeRemovedMembers is true, then members who left or were removed from a team/channel will
|
||||
// If reAddRemovedMembers is true, then members who left or were removed from a team/channel will
|
||||
// be re-added; otherwise, they will not be re-added.
|
||||
func (a *App) SyncLdap(c request.CTX, includeRemovedMembers bool) {
|
||||
func (a *App) SyncLdap(c request.CTX, reAddRemovedMembers *bool) {
|
||||
a.Srv().Go(func() {
|
||||
if license := a.Srv().License(); license != nil && *license.Features.LDAP {
|
||||
if !*a.Config().LdapSettings.EnableSync {
|
||||
@@ -30,7 +30,7 @@ func (a *App) SyncLdap(c request.CTX, includeRemovedMembers bool) {
|
||||
c.Logger().Error("Not executing ldap sync because ldap is not available")
|
||||
return
|
||||
}
|
||||
if _, appErr := ldapI.StartSynchronizeJob(c, false, includeRemovedMembers); appErr != nil {
|
||||
if _, appErr := ldapI.StartSynchronizeJob(c, false, reAddRemovedMembers); appErr != nil {
|
||||
c.Logger().Error("Failed to start LDAP sync job")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
// createDefaultChannelMemberships adds users to channels based on their group memberships and how those groups are
|
||||
// configured to sync with channels for group members on or after the given timestamp. If a channelID is given
|
||||
// only that channel's members are created. If channelID is nil all channel memberships are created.
|
||||
// If includeRemovedMembers is true, then channel members who left or were removed from the channel will
|
||||
// If params.ReAddRemovedMembers is true, then channel members who left or were removed from the channel will
|
||||
// be re-added; otherwise, they will not be re-added.
|
||||
func (a *App) createDefaultChannelMemberships(rctx request.CTX, params model.CreateDefaultMembershipParams) error {
|
||||
channelMembers, appErr := a.ChannelMembersToAdd(params.Since, params.ScopedChannelID, params.ReAddRemovedMembers)
|
||||
@@ -86,7 +86,7 @@ func (a *App) createDefaultChannelMemberships(rctx request.CTX, params model.Cre
|
||||
// createDefaultTeamMemberships adds users to teams based on their group memberships and how those groups are
|
||||
// configured to sync with teams for group members on or after the given timestamp. If a teamID is given
|
||||
// only that team's members are created. If teamID is nil all team memberships are created.
|
||||
// If includeRemovedMembers is true, then team members who left or were removed from the team will
|
||||
// If params.ReAddRemovedMembers is true, then team members who left or were removed from the team will
|
||||
// be re-added; otherwise, they will not be re-added.
|
||||
func (a *App) createDefaultTeamMemberships(rctx request.CTX, params model.CreateDefaultMembershipParams) error {
|
||||
teamMembers, appErr := a.TeamMembersToAdd(params.Since, params.ScopedTeamID, params.ReAddRemovedMembers)
|
||||
@@ -123,7 +123,7 @@ func (a *App) createDefaultTeamMemberships(rctx request.CTX, params model.Create
|
||||
|
||||
// CreateDefaultMemberships adds users to teams and channels based on their group memberships and how those groups
|
||||
// are configured to sync with teams and channels for group members on or after the given timestamp.
|
||||
// If includeRemovedMembers is true, then members who left or were removed from a team/channel will
|
||||
// If params.AddRemovedMembers is true, then members who left or were removed from a team/channel will
|
||||
// be re-added; otherwise, they will not be re-added.
|
||||
func (a *App) CreateDefaultMemberships(rctx request.CTX, params model.CreateDefaultMembershipParams) error {
|
||||
err := a.createDefaultTeamMemberships(rctx, params)
|
||||
@@ -283,17 +283,17 @@ func (a *App) SyncRolesAndMembership(rctx request.CTX, syncableID string, syncab
|
||||
}
|
||||
|
||||
var since int64
|
||||
includeRemovedMembers := true
|
||||
reAddRemovedMembers := true
|
||||
if group.Source == model.GroupSourceLdap {
|
||||
lastJob, _ := a.Srv().Store().Job().GetNewestJobByStatusAndType(model.JobStatusSuccess, model.JobTypeLdapSync)
|
||||
if lastJob != nil {
|
||||
since = lastJob.StartAt
|
||||
}
|
||||
|
||||
includeRemovedMembers = false
|
||||
reAddRemovedMembers = *a.Config().LdapSettings.ReAddRemovedMembers
|
||||
}
|
||||
|
||||
params := model.CreateDefaultMembershipParams{Since: since, ReAddRemovedMembers: includeRemovedMembers}
|
||||
params := model.CreateDefaultMembershipParams{Since: since, ReAddRemovedMembers: reAddRemovedMembers}
|
||||
|
||||
switch syncableType {
|
||||
case model.GroupSyncableTypeTeam:
|
||||
|
||||
Ссылка в новой задаче
Block a user