summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2018-10-08 16:39:03 +0100
committerGitHub <noreply@github.com>2018-10-08 16:39:03 +0100
commit9a4f3ce1e5b22a297eeb00b2aaff44f88304ae8c (patch)
tree8841d645463b21a175036399e78ecae647922e55 /cmd
parent7b338c161bce8bdede54d85a5df5a0efe34eb874 (diff)
downloadchat-9a4f3ce1e5b22a297eeb00b2aaff44f88304ae8c.tar.gz
chat-9a4f3ce1e5b22a297eeb00b2aaff44f88304ae8c.tar.bz2
chat-9a4f3ce1e5b22a297eeb00b2aaff44f88304ae8c.zip
MM-12251: Add flag to MoveChannel to remove all deactivated users. (#9515)
Diffstat (limited to 'cmd')
-rw-r--r--cmd/mattermost/commands/channel.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/cmd/mattermost/commands/channel.go b/cmd/mattermost/commands/channel.go
index 7fb8fea8c..82fb1e966 100644
--- a/cmd/mattermost/commands/channel.go
+++ b/cmd/mattermost/commands/channel.go
@@ -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
}