gh-4759 add system message feedbak for expand/collapse command (#4761)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
40afc39684
Коммит
b5fcfd608c
@@ -4,6 +4,8 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/mattermost/platform/model"
|
"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 {
|
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 {
|
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{
|
pref := model.Preference{
|
||||||
UserId: c.Session.UserId,
|
UserId: c.Session.UserId,
|
||||||
Category: model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS,
|
Category: model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS,
|
||||||
Name: model.PREFERENCE_NAME_COLLAPSE_SETTING,
|
Name: model.PREFERENCE_NAME_COLLAPSE_SETTING,
|
||||||
Value: value,
|
Value: strconv.FormatBool(isCollapse),
|
||||||
}
|
}
|
||||||
|
|
||||||
if result := <-Srv.Store.Preference().Save(&model.Preferences{pref}); result.Err != nil {
|
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())
|
socketMessage.Add("preference", pref.ToJson())
|
||||||
go Publish(socketMessage)
|
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}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -467,6 +467,10 @@
|
|||||||
"id": "api.command_collapse.name",
|
"id": "api.command_collapse.name",
|
||||||
"translation": "collapse"
|
"translation": "collapse"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "api.command_collapse.success",
|
||||||
|
"translation": "Image links now collapse by default"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "api.command_echo.create.app_error",
|
"id": "api.command_echo.create.app_error",
|
||||||
"translation": "Unable to create /echo post, err=%v"
|
"translation": "Unable to create /echo post, err=%v"
|
||||||
@@ -499,6 +503,10 @@
|
|||||||
"id": "api.command_expand.name",
|
"id": "api.command_expand.name",
|
||||||
"translation": "expand"
|
"translation": "expand"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "api.command_expand.success",
|
||||||
|
"translation": "Image links now expand by default"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "api.command_expand_collapse.fail.app_error",
|
"id": "api.command_expand_collapse.fail.app_error",
|
||||||
"translation": "An error occured while expanding previews"
|
"translation": "An error occured while expanding previews"
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user