summaryrefslogtreecommitdiffstats
path: root/api/command_expand_collapse.go
diff options
context:
space:
mode:
authorYusuke Nemoto <kaakaa@users.noreply.github.com>2016-12-12 14:26:53 +0900
committerCorey Hulen <corey@hulen.com>2016-12-11 21:26:53 -0800
commitb5fcfd608c0e9ef764cace7328653e4d4c47a061 (patch)
tree55e68a8e677ab2fcb073dfbe6d59c40393556a08 /api/command_expand_collapse.go
parent40afc39684890d9560f3ff34a9435c003dbba999 (diff)
downloadchat-b5fcfd608c0e9ef764cace7328653e4d4c47a061.tar.gz
chat-b5fcfd608c0e9ef764cace7328653e4d4c47a061.tar.bz2
chat-b5fcfd608c0e9ef764cace7328653e4d4c47a061.zip
gh-4759 add system message feedbak for expand/collapse command (#4761)
Diffstat (limited to 'api/command_expand_collapse.go')
-rw-r--r--api/command_expand_collapse.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/api/command_expand_collapse.go b/api/command_expand_collapse.go
index afd17a6fc..d36893cb0 100644
--- a/api/command_expand_collapse.go
+++ b/api/command_expand_collapse.go
@@ -4,6 +4,8 @@
package api
import (
+ "strconv"
+
"github.com/mattermost/platform/model"
)
@@ -50,19 +52,19 @@ func (me *CollapseProvider) GetCommand(c *Context) *model.Command {
}
func (me *ExpandProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse {
- return setCollapsePreference(c, "false")
+ return setCollapsePreference(c, false)
}
func (me *CollapseProvider) DoCommand(c *Context, args *model.CommandArgs, message string) *model.CommandResponse {
- return setCollapsePreference(c, "true")
+ return setCollapsePreference(c, true)
}
-func setCollapsePreference(c *Context, value string) *model.CommandResponse {
+func setCollapsePreference(c *Context, isCollapse bool) *model.CommandResponse {
pref := model.Preference{
UserId: c.Session.UserId,
Category: model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS,
Name: model.PREFERENCE_NAME_COLLAPSE_SETTING,
- Value: value,
+ Value: strconv.FormatBool(isCollapse),
}
if result := <-Srv.Store.Preference().Save(&model.Preferences{pref}); result.Err != nil {
@@ -73,5 +75,12 @@ func setCollapsePreference(c *Context, value string) *model.CommandResponse {
socketMessage.Add("preference", pref.ToJson())
go Publish(socketMessage)
- return &model.CommandResponse{}
+ var rmsg string
+
+ if isCollapse {
+ rmsg = c.T("api.command_collapse.success")
+ } else {
+ rmsg = c.T("api.command_expand.success")
+ }
+ return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: rmsg}
}