diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-03-13 09:23:16 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-03-13 09:23:16 -0400 |
commit | e9c6cc269b5c9fe82e5f38d63344a07365bccd6b (patch) | |
tree | 711fefd3511dbd5a7f1a20225f00b766eb4808f7 /api/command_shortcuts.go | |
parent | 8b0eedbbcd47ba09142c72a71969840aa6e121d2 (diff) | |
download | chat-e9c6cc269b5c9fe82e5f38d63344a07365bccd6b.tar.gz chat-e9c6cc269b5c9fe82e5f38d63344a07365bccd6b.tar.bz2 chat-e9c6cc269b5c9fe82e5f38d63344a07365bccd6b.zip |
Move command logic into app layer (#5617)
Diffstat (limited to 'api/command_shortcuts.go')
-rw-r--r-- | api/command_shortcuts.go | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/api/command_shortcuts.go b/api/command_shortcuts.go deleted file mode 100644 index 1664221c1..000000000 --- a/api/command_shortcuts.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -package api - -import ( - "bytes" - "strings" - - "github.com/mattermost/platform/model" -) - -type ShortcutsProvider struct { -} - -const ( - CMD_SHORTCUTS = "shortcuts" -) - -func init() { - RegisterCommandProvider(&ShortcutsProvider{}) -} - -func (me *ShortcutsProvider) GetTrigger() string { - return CMD_SHORTCUTS -} - -func (me *ShortcutsProvider) GetCommand(c *Context) *model.Command { - return &model.Command{ - Trigger: CMD_SHORTCUTS, - AutoComplete: true, - AutoCompleteDesc: c.T("api.command_shortcuts.desc"), - AutoCompleteHint: "", - DisplayName: c.T("api.command_shortcuts.name"), - } -} - -func (me *ShortcutsProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse { - shortcutIds := [28]string{ - "api.command_shortcuts.header", - // Nav shortcuts - "api.command_shortcuts.nav.header", - "api.command_shortcuts.nav.prev", - "api.command_shortcuts.nav.next", - "api.command_shortcuts.nav.unread_prev", - "api.command_shortcuts.nav.unread_next", - "api.command_shortcuts.nav.switcher", - "api.command_shortcuts.nav.settings", - "api.command_shortcuts.nav.recent_mentions", - // Files shortcuts - "api.command_shortcuts.files.header", - "api.command_shortcuts.files.upload", - // Msg shortcuts - "api.command_shortcuts.msgs.header", - "api.command_shortcuts.msgs.mark_as_read", - "api.command_shortcuts.msgs.reprint_prev", - "api.command_shortcuts.msgs.reprint_next", - "api.command_shortcuts.msgs.edit", - "api.command_shortcuts.msgs.comp_username", - "api.command_shortcuts.msgs.comp_channel", - "api.command_shortcuts.msgs.comp_emoji", - // Browser shortcuts - "api.command_shortcuts.browser.header", - "api.command_shortcuts.browser.channel_prev", - "api.command_shortcuts.browser.channel_next", - "api.command_shortcuts.browser.font_increase", - "api.command_shortcuts.browser.font_decrease", - "api.command_shortcuts.browser.highlight_prev", - "api.command_shortcuts.browser.highlight_next", - "api.command_shortcuts.browser.newline", - } - - var osDependentWords map[string]interface{} - if strings.Contains(message, "mac") { - osDependentWords = map[string]interface{}{ - "CmdOrCtrl": c.T("api.command_shortcuts.cmd"), - "ChannelPrevCmd": c.T("api.command_shortcuts.browser.channel_prev.cmd_mac"), - "ChannelNextCmd": c.T("api.command_shortcuts.browser.channel_next.cmd_mac"), - } - } else { - osDependentWords = map[string]interface{}{ - "CmdOrCtrl": c.T("api.command_shortcuts.ctrl"), - "ChannelPrevCmd": c.T("api.command_shortcuts.browser.channel_prev.cmd"), - "ChannelNextCmd": c.T("api.command_shortcuts.browser.channel_next.cmd"), - } - } - - var buffer bytes.Buffer - for _, element := range shortcutIds { - buffer.WriteString(c.T(element, osDependentWords)) - } - - return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: buffer.String()} -} |