diff options
Diffstat (limited to 'api')
-rw-r--r-- | api/command.go | 32 | ||||
-rw-r--r-- | api/command_away.go | 2 | ||||
-rw-r--r-- | api/command_echo.go | 6 | ||||
-rw-r--r-- | api/command_echo_test.go | 2 | ||||
-rw-r--r-- | api/command_expand_collapse.go | 4 | ||||
-rw-r--r-- | api/command_expand_collapse_test.go | 4 | ||||
-rw-r--r-- | api/command_invite_people.go | 2 | ||||
-rw-r--r-- | api/command_invite_people_test.go | 6 | ||||
-rw-r--r-- | api/command_join.go | 2 | ||||
-rw-r--r-- | api/command_join_test.go | 4 | ||||
-rw-r--r-- | api/command_loadtest.go | 3 | ||||
-rw-r--r-- | api/command_loadtest_test.go | 10 | ||||
-rw-r--r-- | api/command_logout.go | 2 | ||||
-rw-r--r-- | api/command_logout_test.go | 2 | ||||
-rw-r--r-- | api/command_me.go | 2 | ||||
-rw-r--r-- | api/command_me_test.go | 2 | ||||
-rw-r--r-- | api/command_msg.go | 2 | ||||
-rw-r--r-- | api/command_msg_test.go | 6 | ||||
-rw-r--r-- | api/command_offline.go | 2 | ||||
-rw-r--r-- | api/command_online.go | 2 | ||||
-rw-r--r-- | api/command_shortcuts.go | 2 | ||||
-rw-r--r-- | api/command_shortcuts_test.go | 4 | ||||
-rw-r--r-- | api/command_shrug.go | 2 | ||||
-rw-r--r-- | api/command_shrug_test.go | 2 | ||||
-rw-r--r-- | api/command_statuses_test.go | 2 | ||||
-rw-r--r-- | api/command_test.go | 4 |
26 files changed, 58 insertions, 55 deletions
diff --git a/api/command.go b/api/command.go index 3ae379819..a6c3ea201 100644 --- a/api/command.go +++ b/api/command.go @@ -20,7 +20,7 @@ import ( type CommandProvider interface { GetTrigger() string GetCommand(c *Context) *model.Command - DoCommand(c *Context, channelId string, message string) *model.CommandResponse + DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse } var commandProviders = make(map[string]CommandProvider) @@ -88,30 +88,28 @@ func listCommands(c *Context, w http.ResponseWriter, r *http.Request) { } func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) { - props := model.MapFromJson(r.Body) - command := strings.TrimSpace(props["command"]) - channelId := strings.TrimSpace(props["channelId"]) + commandArgs := model.CommandArgsFromJson(r.Body) - if len(command) <= 1 || strings.Index(command, "/") != 0 { + if len(commandArgs.Command) <= 1 || strings.Index(commandArgs.Command, "/") != 0 { c.Err = model.NewLocAppError("executeCommand", "api.command.execute_command.start.app_error", nil, "") return } - if len(channelId) > 0 { - if !HasPermissionToChannelContext(c, channelId, model.PERMISSION_USE_SLASH_COMMANDS) { + if len(commandArgs.ChannelId) > 0 { + if !HasPermissionToChannelContext(c, commandArgs.ChannelId, model.PERMISSION_USE_SLASH_COMMANDS) { return } } - parts := strings.Split(command, " ") + parts := strings.Split(commandArgs.Command, " ") trigger := parts[0][1:] trigger = strings.ToLower(trigger) message := strings.Join(parts[1:], " ") provider := GetCommandProvider(trigger) if provider != nil { - response := provider.DoCommand(c, channelId, message) - handleResponse(c, w, response, channelId, provider.GetCommand(c), true) + response := provider.DoCommand(c, commandArgs, message) + handleResponse(c, w, response, commandArgs, provider.GetCommand(c), true) return } else { @@ -121,7 +119,7 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) { return } - chanChan := Srv.Store.Channel().Get(channelId) + chanChan := Srv.Store.Channel().Get(commandArgs.ChannelId) teamChan := Srv.Store.Team().Get(c.TeamId) userChan := Srv.Store.User().Get(c.Session.UserId) @@ -166,7 +164,7 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) { p.Set("team_id", cmd.TeamId) p.Set("team_domain", team.Name) - p.Set("channel_id", channelId) + p.Set("channel_id", commandArgs.ChannelId) p.Set("channel_name", channel.Name) p.Set("user_id", c.Session.UserId) @@ -200,7 +198,7 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) { if response == nil { c.Err = model.NewLocAppError("command", "api.command.execute_command.failed_empty.app_error", map[string]interface{}{"Trigger": trigger}, "") } else { - handleResponse(c, w, response, channelId, cmd, false) + handleResponse(c, w, response, commandArgs, cmd, false) } } else { defer resp.Body.Close() @@ -219,10 +217,11 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) { c.Err = model.NewLocAppError("command", "api.command.execute_command.not_found.app_error", map[string]interface{}{"Trigger": trigger}, "") } -func handleResponse(c *Context, w http.ResponseWriter, response *model.CommandResponse, channelId string, cmd *model.Command, builtIn bool) { - +func handleResponse(c *Context, w http.ResponseWriter, response *model.CommandResponse, commandArgs *model.CommandArgs, cmd *model.Command, builtIn bool) { post := &model.Post{} - post.ChannelId = channelId + post.ChannelId = commandArgs.ChannelId + post.RootId = commandArgs.RootId + post.ParentId = commandArgs.ParentId if !builtIn { post.AddProp("from_webhook", "true") @@ -258,6 +257,7 @@ func handleResponse(c *Context, w http.ResponseWriter, response *model.CommandRe post.Message = response.Text post.CreateAt = model.GetMillis() post.UserId = c.Session.UserId + post.ParentId = "" SendEphemeralPost( c.TeamId, c.Session.UserId, diff --git a/api/command_away.go b/api/command_away.go index 55ce7846e..6d6540320 100644 --- a/api/command_away.go +++ b/api/command_away.go @@ -31,7 +31,7 @@ func (me *AwayProvider) GetCommand(c *Context) *model.Command { } } -func (me *AwayProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { +func (me *AwayProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { rmsg := c.T("api.command_away.success") if len(message) > 0 { rmsg = message + " " + rmsg diff --git a/api/command_echo.go b/api/command_echo.go index 997ee0751..4f6f6e33a 100644 --- a/api/command_echo.go +++ b/api/command_echo.go @@ -39,7 +39,7 @@ func (me *EchoProvider) GetCommand(c *Context) *model.Command { } } -func (me *EchoProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { +func (me *EchoProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { maxThreads := 100 delay := 0 @@ -75,7 +75,9 @@ func (me *EchoProvider) DoCommand(c *Context, channelId string, message string) go func() { defer func() { <-echoSem }() post := &model.Post{} - post.ChannelId = channelId + post.ChannelId = args.ChannelId + post.RootId = args.RootId + post.ParentId = args.ParentId post.Message = message post.UserId = c.Session.UserId diff --git a/api/command_echo_test.go b/api/command_echo_test.go index 26fba007c..71a378242 100644 --- a/api/command_echo_test.go +++ b/api/command_echo_test.go @@ -17,7 +17,7 @@ func TestEchoCommand(t *testing.T) { echoTestString := "/echo test" - r1 := Client.Must(Client.Command(channel1.Id, echoTestString, false)).Data.(*model.CommandResponse) + r1 := Client.Must(Client.Command(channel1.Id, echoTestString)).Data.(*model.CommandResponse) if r1 == nil { t.Fatal("Echo command failed to execute") } diff --git a/api/command_expand_collapse.go b/api/command_expand_collapse.go index ee018cf8f..afd17a6fc 100644 --- a/api/command_expand_collapse.go +++ b/api/command_expand_collapse.go @@ -49,11 +49,11 @@ func (me *CollapseProvider) GetCommand(c *Context) *model.Command { } } -func (me *ExpandProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { +func (me *ExpandProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { return setCollapsePreference(c, "false") } -func (me *CollapseProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { +func (me *CollapseProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { return setCollapsePreference(c, "true") } diff --git a/api/command_expand_collapse_test.go b/api/command_expand_collapse_test.go index 2303b2fed..bad5ef6c4 100644 --- a/api/command_expand_collapse_test.go +++ b/api/command_expand_collapse_test.go @@ -15,7 +15,7 @@ func TestExpandCommand(t *testing.T) { Client := th.BasicClient channel := th.BasicChannel - r1 := Client.Must(Client.Command(channel.Id, "/expand", false)).Data.(*model.CommandResponse) + r1 := Client.Must(Client.Command(channel.Id, "/expand")).Data.(*model.CommandResponse) if r1 == nil { t.Fatal("Command failed to execute") } @@ -33,7 +33,7 @@ func TestCollapseCommand(t *testing.T) { Client := th.BasicClient channel := th.BasicChannel - r1 := Client.Must(Client.Command(channel.Id, "/collapse", false)).Data.(*model.CommandResponse) + r1 := Client.Must(Client.Command(channel.Id, "/collapse")).Data.(*model.CommandResponse) if r1 == nil { t.Fatal("Command failed to execute") } diff --git a/api/command_invite_people.go b/api/command_invite_people.go index 93f8f85eb..ca2a2633a 100644 --- a/api/command_invite_people.go +++ b/api/command_invite_people.go @@ -35,7 +35,7 @@ func (me *InvitePeopleProvider) GetCommand(c *Context) *model.Command { } } -func (me *InvitePeopleProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { +func (me *InvitePeopleProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { if !utils.Cfg.EmailSettings.SendEmailNotifications { return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: c.T("api.command.invite_people.email_off")} } diff --git a/api/command_invite_people_test.go b/api/command_invite_people_test.go index 3efc87e60..d4f579c4d 100644 --- a/api/command_invite_people_test.go +++ b/api/command_invite_people_test.go @@ -14,17 +14,17 @@ func TestInvitePeopleCommand(t *testing.T) { Client := th.BasicClient channel := th.BasicChannel - r1 := Client.Must(Client.Command(channel.Id, "/invite_people test@example.com", false)).Data.(*model.CommandResponse) + r1 := Client.Must(Client.Command(channel.Id, "/invite_people test@example.com")).Data.(*model.CommandResponse) if r1 == nil { t.Fatal("Command failed to execute") } - r2 := Client.Must(Client.Command(channel.Id, "/invite_people test1@example.com test2@example.com", false)).Data.(*model.CommandResponse) + r2 := Client.Must(Client.Command(channel.Id, "/invite_people test1@example.com test2@example.com")).Data.(*model.CommandResponse) if r2 == nil { t.Fatal("Command failed to execute") } - r3 := Client.Must(Client.Command(channel.Id, "/invite_people", false)).Data.(*model.CommandResponse) + r3 := Client.Must(Client.Command(channel.Id, "/invite_people")).Data.(*model.CommandResponse) if r3 == nil { t.Fatal("Command failed to execute") } diff --git a/api/command_join.go b/api/command_join.go index 0499d503d..3c997dffd 100644 --- a/api/command_join.go +++ b/api/command_join.go @@ -32,7 +32,7 @@ func (me *JoinProvider) GetCommand(c *Context) *model.Command { } } -func (me *JoinProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { +func (me *JoinProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { if result := <-Srv.Store.Channel().GetByName(c.TeamId, message); result.Err != nil { return &model.CommandResponse{Text: c.T("api.command_join.list.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL} } else { diff --git a/api/command_join_test.go b/api/command_join_test.go index a1dbace41..cce837ceb 100644 --- a/api/command_join_test.go +++ b/api/command_join_test.go @@ -29,12 +29,12 @@ func TestJoinCommands(t *testing.T) { channel3 := Client.Must(Client.CreateDirectChannel(user2.Id)).Data.(*model.Channel) - rs5 := Client.Must(Client.Command(channel0.Id, "/join "+channel2.Name, false)).Data.(*model.CommandResponse) + rs5 := Client.Must(Client.Command(channel0.Id, "/join "+channel2.Name)).Data.(*model.CommandResponse) if !strings.HasSuffix(rs5.GotoLocation, "/"+team.Name+"/channels/"+channel2.Name) { t.Fatal("failed to join channel") } - rs6 := Client.Must(Client.Command(channel0.Id, "/join "+channel3.Name, false)).Data.(*model.CommandResponse) + rs6 := Client.Must(Client.Command(channel0.Id, "/join "+channel3.Name)).Data.(*model.CommandResponse) if strings.HasSuffix(rs6.GotoLocation, "/"+team.Name+"/channels/"+channel3.Name) { t.Fatal("should not have joined direct message channel") } diff --git a/api/command_loadtest.go b/api/command_loadtest.go index 8f5163a66..ed3fc37ba 100644 --- a/api/command_loadtest.go +++ b/api/command_loadtest.go @@ -84,7 +84,8 @@ func (me *LoadTestProvider) GetCommand(c *Context) *model.Command { } } -func (me *LoadTestProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { +func (me *LoadTestProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { + channelId := args.ChannelId //This command is only available when EnableTesting is true if !utils.Cfg.ServiceSettings.EnableTesting { diff --git a/api/command_loadtest_test.go b/api/command_loadtest_test.go index 9371e5960..091e05831 100644 --- a/api/command_loadtest_test.go +++ b/api/command_loadtest_test.go @@ -25,7 +25,7 @@ func TestLoadTestHelpCommands(t *testing.T) { utils.Cfg.ServiceSettings.EnableTesting = true - rs := Client.Must(Client.Command(channel.Id, "/loadtest help", false)).Data.(*model.CommandResponse) + rs := Client.Must(Client.Command(channel.Id, "/loadtest help")).Data.(*model.CommandResponse) if !strings.Contains(rs.Text, "Mattermost load testing commands to help") { t.Fatal(rs.Text) } @@ -46,7 +46,7 @@ func TestLoadTestSetupCommands(t *testing.T) { utils.Cfg.ServiceSettings.EnableTesting = true - rs := Client.Must(Client.Command(channel.Id, "/loadtest setup fuzz 1 1 1", false)).Data.(*model.CommandResponse) + rs := Client.Must(Client.Command(channel.Id, "/loadtest setup fuzz 1 1 1")).Data.(*model.CommandResponse) if rs.Text != "Created enviroment" { t.Fatal(rs.Text) } @@ -67,7 +67,7 @@ func TestLoadTestUsersCommands(t *testing.T) { utils.Cfg.ServiceSettings.EnableTesting = true - rs := Client.Must(Client.Command(channel.Id, "/loadtest users fuzz 1 2", false)).Data.(*model.CommandResponse) + rs := Client.Must(Client.Command(channel.Id, "/loadtest users fuzz 1 2")).Data.(*model.CommandResponse) if rs.Text != "Added users" { t.Fatal(rs.Text) } @@ -88,7 +88,7 @@ func TestLoadTestChannelsCommands(t *testing.T) { utils.Cfg.ServiceSettings.EnableTesting = true - rs := Client.Must(Client.Command(channel.Id, "/loadtest channels fuzz 1 2", false)).Data.(*model.CommandResponse) + rs := Client.Must(Client.Command(channel.Id, "/loadtest channels fuzz 1 2")).Data.(*model.CommandResponse) if rs.Text != "Added channels" { t.Fatal(rs.Text) } @@ -109,7 +109,7 @@ func TestLoadTestPostsCommands(t *testing.T) { utils.Cfg.ServiceSettings.EnableTesting = true - rs := Client.Must(Client.Command(channel.Id, "/loadtest posts fuzz 2 3 2", false)).Data.(*model.CommandResponse) + rs := Client.Must(Client.Command(channel.Id, "/loadtest posts fuzz 2 3 2")).Data.(*model.CommandResponse) if rs.Text != "Added posts" { t.Fatal(rs.Text) } diff --git a/api/command_logout.go b/api/command_logout.go index 9fff4e2d5..474f0b58e 100644 --- a/api/command_logout.go +++ b/api/command_logout.go @@ -32,7 +32,7 @@ func (me *LogoutProvider) GetCommand(c *Context) *model.Command { } } -func (me *LogoutProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { +func (me *LogoutProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { FAIL := &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: c.T("api.command_logout.fail_message")} SUCCESS := &model.CommandResponse{GotoLocation: "/", ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: c.T("api.command_logout.success_message")} diff --git a/api/command_logout_test.go b/api/command_logout_test.go index 6d74549af..d61b30633 100644 --- a/api/command_logout_test.go +++ b/api/command_logout_test.go @@ -10,5 +10,5 @@ import ( func TestLogoutTestCommand(t *testing.T) { th := Setup().InitBasic() - th.BasicClient.Must(th.BasicClient.Command(th.BasicChannel.Id, "/logout", false)) + th.BasicClient.Must(th.BasicClient.Command(th.BasicChannel.Id, "/logout")) } diff --git a/api/command_me.go b/api/command_me.go index c6147278b..a3cda472a 100644 --- a/api/command_me.go +++ b/api/command_me.go @@ -32,6 +32,6 @@ func (me *MeProvider) GetCommand(c *Context) *model.Command { } } -func (me *MeProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { +func (me *MeProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_IN_CHANNEL, Text: "*" + message + "*"} } diff --git a/api/command_me_test.go b/api/command_me_test.go index f466f5764..0250cfb0f 100644 --- a/api/command_me_test.go +++ b/api/command_me_test.go @@ -17,7 +17,7 @@ func TestMeCommand(t *testing.T) { testString := "/me hello" - r1 := Client.Must(Client.Command(channel.Id, testString, false)).Data.(*model.CommandResponse) + r1 := Client.Must(Client.Command(channel.Id, testString)).Data.(*model.CommandResponse) if r1 == nil { t.Fatal("Command failed to execute") } diff --git a/api/command_msg.go b/api/command_msg.go index 2e0e25397..8a9949544 100644 --- a/api/command_msg.go +++ b/api/command_msg.go @@ -34,7 +34,7 @@ func (me *msgProvider) GetCommand(c *Context) *model.Command { } } -func (me *msgProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { +func (me *msgProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { splitMessage := strings.SplitN(message, " ", 2) diff --git a/api/command_msg_test.go b/api/command_msg_test.go index f11fce091..ad1c8d5ce 100644 --- a/api/command_msg_test.go +++ b/api/command_msg_test.go @@ -21,12 +21,12 @@ func TestMsgCommands(t *testing.T) { Client.Must(Client.CreateDirectChannel(user2.Id)) Client.Must(Client.CreateDirectChannel(user3.Id)) - rs1 := Client.Must(Client.Command("", "/msg "+user2.Username, false)).Data.(*model.CommandResponse) + rs1 := Client.Must(Client.Command("", "/msg "+user2.Username)).Data.(*model.CommandResponse) if !strings.HasSuffix(rs1.GotoLocation, "/"+team.Name+"/channels/"+user1.Id+"__"+user2.Id) && !strings.HasSuffix(rs1.GotoLocation, "/"+team.Name+"/channels/"+user2.Id+"__"+user1.Id) { t.Fatal("failed to create direct channel") } - rs2 := Client.Must(Client.Command("", "/msg "+user3.Username+" foobar", false)).Data.(*model.CommandResponse) + rs2 := Client.Must(Client.Command("", "/msg "+user3.Username+" foobar")).Data.(*model.CommandResponse) if !strings.HasSuffix(rs2.GotoLocation, "/"+team.Name+"/channels/"+user1.Id+"__"+user3.Id) && !strings.HasSuffix(rs2.GotoLocation, "/"+team.Name+"/channels/"+user3.Id+"__"+user1.Id) { t.Fatal("failed to create second direct channel") } @@ -34,7 +34,7 @@ func TestMsgCommands(t *testing.T) { t.Fatalf("post did not get sent to direct message") } - rs3 := Client.Must(Client.Command("", "/msg "+user2.Username, false)).Data.(*model.CommandResponse) + rs3 := Client.Must(Client.Command("", "/msg "+user2.Username)).Data.(*model.CommandResponse) if !strings.HasSuffix(rs3.GotoLocation, "/"+team.Name+"/channels/"+user1.Id+"__"+user2.Id) && !strings.HasSuffix(rs3.GotoLocation, "/"+team.Name+"/channels/"+user2.Id+"__"+user1.Id) { t.Fatal("failed to go back to existing direct channel") } diff --git a/api/command_offline.go b/api/command_offline.go index a9e2123d3..1349ac18f 100644 --- a/api/command_offline.go +++ b/api/command_offline.go @@ -31,7 +31,7 @@ func (me *OfflineProvider) GetCommand(c *Context) *model.Command { } } -func (me *OfflineProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { +func (me *OfflineProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { rmsg := c.T("api.command_offline.success") if len(message) > 0 { rmsg = message + " " + rmsg diff --git a/api/command_online.go b/api/command_online.go index 71ada5b7a..887aa2c47 100644 --- a/api/command_online.go +++ b/api/command_online.go @@ -31,7 +31,7 @@ func (me *OnlineProvider) GetCommand(c *Context) *model.Command { } } -func (me *OnlineProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { +func (me *OnlineProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { rmsg := c.T("api.command_online.success") if len(message) > 0 { rmsg = message + " " + rmsg diff --git a/api/command_shortcuts.go b/api/command_shortcuts.go index dfbb7071d..f75b419b1 100644 --- a/api/command_shortcuts.go +++ b/api/command_shortcuts.go @@ -35,7 +35,7 @@ func (me *ShortcutsProvider) GetCommand(c *Context) *model.Command { } } -func (me *ShortcutsProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { +func (me *ShortcutsProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { shortcutIds := [4]string{ "api.command_shortcuts.nav", "api.command_shortcuts.files", diff --git a/api/command_shortcuts_test.go b/api/command_shortcuts_test.go index 01c56b465..049175ec9 100644 --- a/api/command_shortcuts_test.go +++ b/api/command_shortcuts_test.go @@ -14,12 +14,12 @@ func TestShortcutsCommand(t *testing.T) { Client := th.BasicClient channel := th.BasicChannel - rs := Client.Must(Client.Command(channel.Id, "/shortcuts ", false)).Data.(*model.CommandResponse) + rs := Client.Must(Client.Command(channel.Id, "/shortcuts ")).Data.(*model.CommandResponse) if !strings.Contains(rs.Text, "CTRL") { t.Fatal("failed to display shortcuts") } - rs = Client.Must(Client.Command(channel.Id, "/shortcuts mac", false)).Data.(*model.CommandResponse) + rs = Client.Must(Client.Command(channel.Id, "/shortcuts mac")).Data.(*model.CommandResponse) if !strings.Contains(rs.Text, "CMD") { t.Fatal("failed to display Mac shortcuts") } diff --git a/api/command_shrug.go b/api/command_shrug.go index 8fb5bc200..899fcab33 100644 --- a/api/command_shrug.go +++ b/api/command_shrug.go @@ -32,7 +32,7 @@ func (me *ShrugProvider) GetCommand(c *Context) *model.Command { } } -func (me *ShrugProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse { +func (me *ShrugProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { rmsg := `¯\\\_(ツ)\_/¯` if len(message) > 0 { rmsg = message + " " + rmsg diff --git a/api/command_shrug_test.go b/api/command_shrug_test.go index 99c10d191..e64f4c4b1 100644 --- a/api/command_shrug_test.go +++ b/api/command_shrug_test.go @@ -17,7 +17,7 @@ func TestShrugCommand(t *testing.T) { testString := "/shrug" - r1 := Client.Must(Client.Command(channel.Id, testString, false)).Data.(*model.CommandResponse) + r1 := Client.Must(Client.Command(channel.Id, testString)).Data.(*model.CommandResponse) if r1 == nil { t.Fatal("Command failed to execute") } diff --git a/api/command_statuses_test.go b/api/command_statuses_test.go index 73c6354f4..47628de3f 100644 --- a/api/command_statuses_test.go +++ b/api/command_statuses_test.go @@ -22,7 +22,7 @@ func commandAndTest(t *testing.T, th *TestHelper, status string) { channel := th.BasicChannel user := th.BasicUser - r1 := Client.Must(Client.Command(channel.Id, "/"+status, false)).Data.(*model.CommandResponse) + r1 := Client.Must(Client.Command(channel.Id, "/"+status)).Data.(*model.CommandResponse) if r1 == nil { t.Fatal("Command failed to execute") } diff --git a/api/command_test.go b/api/command_test.go index 45268a9a5..726a9cb9b 100644 --- a/api/command_test.go +++ b/api/command_test.go @@ -246,7 +246,7 @@ func TestTestCommand(t *testing.T) { cmd1 = Client.Must(Client.CreateCommand(cmd1)).Data.(*model.Command) - r1 := Client.Must(Client.Command(channel1.Id, "/test", false)).Data.(*model.CommandResponse) + r1 := Client.Must(Client.Command(channel1.Id, "/test")).Data.(*model.CommandResponse) if r1 == nil { t.Fatal("Test command failed to execute") } @@ -266,7 +266,7 @@ func TestTestCommand(t *testing.T) { cmd2 = Client.Must(Client.CreateCommand(cmd2)).Data.(*model.Command) - r2 := Client.Must(Client.Command(channel1.Id, "/test2", false)).Data.(*model.CommandResponse) + r2 := Client.Must(Client.Command(channel1.Id, "/test2")).Data.(*model.CommandResponse) if r2 == nil { t.Fatal("Test2 command failed to execute") } |