diff options
author | Chris <ccbrown112@gmail.com> | 2017-06-26 09:36:47 -0700 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-06-26 09:36:47 -0700 |
commit | 14467ee1347de69aad7d83d305c413a5f0b5f6c2 (patch) | |
tree | f5a6e7e4a07d415b660b9c01eb678f4d304a0717 | |
parent | e285839ee1322b8f16bdd15b76ef2d0f62bf154f (diff) | |
download | chat-14467ee1347de69aad7d83d305c413a5f0b5f6c2.tar.gz chat-14467ee1347de69aad7d83d305c413a5f0b5f6c2.tar.bz2 chat-14467ee1347de69aad7d83d305c413a5f0b5f6c2.zip |
add /open command (#6717)
-rw-r--r-- | api/command_join_test.go | 11 | ||||
-rw-r--r-- | api/command_open_test.go | 12 | ||||
-rw-r--r-- | app/command_open.go | 32 | ||||
-rw-r--r-- | i18n/en.json | 4 |
4 files changed, 56 insertions, 3 deletions
diff --git a/api/command_join_test.go b/api/command_join_test.go index c179175fb..f71b91f41 100644 --- a/api/command_join_test.go +++ b/api/command_join_test.go @@ -10,7 +10,8 @@ import ( "github.com/mattermost/platform/model" ) -func TestJoinCommands(t *testing.T) { +// also used to test /open (see command_open_test.go) +func testJoinCommands(t *testing.T, alias string) { th := Setup().InitBasic() Client := th.BasicClient team := th.BasicTeam @@ -29,12 +30,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)).Data.(*model.CommandResponse) + rs5 := Client.Must(Client.Command(channel0.Id, "/"+alias+" "+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)).Data.(*model.CommandResponse) + rs6 := Client.Must(Client.Command(channel0.Id, "/"+alias+" "+channel3.Name)).Data.(*model.CommandResponse) if strings.HasSuffix(rs6.GotoLocation, "/"+team.Name+"/channels/"+channel3.Name) { t.Fatal("should not have joined direct message channel") } @@ -52,3 +53,7 @@ func TestJoinCommands(t *testing.T) { t.Fatal("did not join channel") } } + +func TestJoinCommands(t *testing.T) { + testJoinCommands(t, "join") +} diff --git a/api/command_open_test.go b/api/command_open_test.go new file mode 100644 index 000000000..61e3861d8 --- /dev/null +++ b/api/command_open_test.go @@ -0,0 +1,12 @@ +// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package api + +import ( + "testing" +) + +func TestOpenCommands(t *testing.T) { + testJoinCommands(t, "open") +} diff --git a/app/command_open.go b/app/command_open.go new file mode 100644 index 000000000..57dbb3f14 --- /dev/null +++ b/app/command_open.go @@ -0,0 +1,32 @@ +// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package app + +import ( + "github.com/mattermost/platform/model" + goi18n "github.com/nicksnyder/go-i18n/i18n" +) + +type OpenProvider struct { + JoinProvider +} + +const ( + CMD_OPEN = "open" +) + +func init() { + RegisterCommandProvider(&OpenProvider{}) +} + +func (open *OpenProvider) GetTrigger() string { + return CMD_OPEN +} + +func (open *OpenProvider) GetCommand(T goi18n.TranslateFunc) *model.Command { + cmd := open.JoinProvider.GetCommand(T) + cmd.Trigger = CMD_OPEN + cmd.DisplayName = T("api.command_open.name") + return cmd +} diff --git a/i18n/en.json b/i18n/en.json index b2e0b7b5c..6a68ed0fc 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -672,6 +672,10 @@ "translation": "The settings command is not supported on your device" }, { + "id": "api.command_open.name", + "translation": "open" + }, + { "id": "api.command_shortcuts.browser.channel_next", "translation": "{{.ChannelNextCmd}}: Next channel in your history\n" }, |