MM-12251: Add flag to MoveChannel to remove all deactivated users. (#9515)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7b338c161b
Коммит
9a4f3ce1e5
@@ -117,6 +117,7 @@ func init() {
|
||||
ChannelCreateCmd.Flags().Bool("private", false, "Create a private channel.")
|
||||
|
||||
MoveChannelsCmd.Flags().String("username", "", "Required. Username who is moving the channel.")
|
||||
MoveChannelsCmd.Flags().Bool("remove-deactivated-users", false, "Automatically remove any deactivated users from the channel before moving it.")
|
||||
|
||||
DeleteChannelsCmd.Flags().Bool("confirm", false, "Confirm you really want to delete the channels.")
|
||||
|
||||
@@ -366,6 +367,8 @@ func moveChannelsCmdF(command *cobra.Command, args []string) error {
|
||||
}
|
||||
user := getUserFromUserArg(a, username)
|
||||
|
||||
removeDeactivatedMembers, _ := command.Flags().GetBool("remove-deactivated-users")
|
||||
|
||||
channels := getChannelsFromChannelArgs(a, args[1:])
|
||||
for i, channel := range channels {
|
||||
if channel == nil {
|
||||
@@ -373,7 +376,7 @@ func moveChannelsCmdF(command *cobra.Command, args []string) error {
|
||||
continue
|
||||
}
|
||||
originTeamID := channel.TeamId
|
||||
if err := moveChannel(a, team, channel, user); err != nil {
|
||||
if err := moveChannel(a, team, channel, user, removeDeactivatedMembers); err != nil {
|
||||
CommandPrintErrorln("Unable to move channel '" + channel.Name + "' error: " + err.Error())
|
||||
} else {
|
||||
CommandPrettyPrintln("Moved channel '" + channel.Name + "' to " + team.Name + "(" + team.Id + ") from " + originTeamID + ".")
|
||||
@@ -383,10 +386,10 @@ func moveChannelsCmdF(command *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func moveChannel(a *app.App, team *model.Team, channel *model.Channel, user *model.User) *model.AppError {
|
||||
func moveChannel(a *app.App, team *model.Team, channel *model.Channel, user *model.User, removeDeactivatedMembers bool) *model.AppError {
|
||||
oldTeamId := channel.TeamId
|
||||
|
||||
if err := a.MoveChannel(team, channel, user); err != nil {
|
||||
if err := a.MoveChannel(team, channel, user, removeDeactivatedMembers); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user