summaryrefslogtreecommitdiffstats
path: root/mattermost.go
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-07-06 13:40:59 -0800
committerGitHub <noreply@github.com>2016-07-06 13:40:59 -0800
commitd5f243dad694d6746ec2b6560a81212a78d8c975 (patch)
tree7f1de697c906ff909f26b739eebaa77f18edf790 /mattermost.go
parent3eee51f74e893f3182519ad0edb72dd5d8b107fd (diff)
downloadchat-d5f243dad694d6746ec2b6560a81212a78d8c975.tar.gz
chat-d5f243dad694d6746ec2b6560a81212a78d8c975.tar.bz2
chat-d5f243dad694d6746ec2b6560a81212a78d8c975.zip
PLT-2863 adding remove user from team (#3429)
* PLT-2863 adding remove user from team * PLT-2863 adding the client side UI * Fixing trailing space * Fixing reported issues * Adding documentatino * Switching to final javascript driver
Diffstat (limited to 'mattermost.go')
-rw-r--r--mattermost.go52
1 files changed, 51 insertions, 1 deletions
diff --git a/mattermost.go b/mattermost.go
index 423e00536..14f297a66 100644
--- a/mattermost.go
+++ b/mattermost.go
@@ -50,6 +50,7 @@ var flagCmdLeaveChannel bool
var flagCmdListChannels bool
var flagCmdRestoreChannel bool
var flagCmdJoinTeam bool
+var flagCmdLeaveTeam bool
var flagCmdVersion bool
var flagCmdRunWebClientTests bool
var flagCmdRunJavascriptClientTests bool
@@ -286,6 +287,7 @@ func parseCmds() {
flag.BoolVar(&flagCmdListChannels, "list_channels", false, "")
flag.BoolVar(&flagCmdRestoreChannel, "restore_channel", false, "")
flag.BoolVar(&flagCmdJoinTeam, "join_team", false, "")
+ flag.BoolVar(&flagCmdLeaveTeam, "leave_team", false, "")
flag.BoolVar(&flagCmdVersion, "version", false, "")
flag.BoolVar(&flagCmdRunWebClientTests, "run_web_client_tests", false, "")
flag.BoolVar(&flagCmdRunJavascriptClientTests, "run_javascript_client_tests", false, "")
@@ -303,6 +305,7 @@ func parseCmds() {
flagRunCmds = (flagCmdCreateTeam ||
flagCmdCreateUser ||
flagCmdInviteUser ||
+ flagCmdLeaveTeam ||
flagCmdAssignRole ||
flagCmdJoinChannel ||
flagCmdLeaveChannel ||
@@ -328,6 +331,7 @@ func runCmds() {
cmdCreateTeam()
cmdCreateUser()
cmdInviteUser()
+ cmdLeaveTeam()
cmdAssignRole()
cmdJoinChannel()
cmdLeaveChannel()
@@ -1187,6 +1191,47 @@ func cmdJoinTeam() {
}
}
+func cmdLeaveTeam() {
+ if flagCmdLeaveTeam {
+ if len(flagTeamName) == 0 {
+ fmt.Fprintln(os.Stderr, "flag needs an argument: -team_name")
+ flag.Usage()
+ os.Exit(1)
+ }
+
+ if len(flagEmail) == 0 {
+ fmt.Fprintln(os.Stderr, "flag needs an argument: -email")
+ flag.Usage()
+ os.Exit(1)
+ }
+
+ var team *model.Team
+ if result := <-api.Srv.Store.Team().GetByName(flagTeamName); result.Err != nil {
+ l4g.Error("%v", result.Err)
+ flushLogAndExit(1)
+ } else {
+ team = result.Data.(*model.Team)
+ }
+
+ var user *model.User
+ if result := <-api.Srv.Store.User().GetByEmail(flagEmail); result.Err != nil {
+ l4g.Error("%v", result.Err)
+ flushLogAndExit(1)
+ } else {
+ user = result.Data.(*model.User)
+ }
+
+ err := api.LeaveTeam(team, user)
+
+ if err != nil {
+ l4g.Error("%v", err)
+ flushLogAndExit(1)
+ }
+
+ os.Exit(0)
+ }
+}
+
func cmdResetPassword() {
if flagCmdResetPassword {
if len(flagEmail) == 0 {
@@ -1517,7 +1562,12 @@ COMMANDS:
Example:
platform -invite_user -team_name="name" -email="user@example.com" -site_url="https://mattermost.example.com"
- -join_team Joins a user to the team. It requires the -email and
+-leave_team Removes a user from a team. It requires the -team_name
+ and -email.
+ Example:
+ platform -remove_user_from_team -team_name="name" -email="user@example.com"
+
+ -join_team Joins a user to the team. It required the -email and
-team_name. You may need to logout of your current session
for the new team to be applied.
Example: