Adding loc to new command backend

Этот коммит содержится в:
=Corey Hulen
2016-02-01 18:52:43 -08:00
родитель b4ec690051
Коммит 27586a320a
12 изменённых файлов: 297 добавлений и 276 удалений

Просмотреть файл

@@ -4,6 +4,7 @@
package api
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
@@ -16,14 +17,15 @@ import (
)
type CommandProvider interface {
GetCommand() *model.Command
GetTrigger() string
GetCommand(c *Context) *model.Command
DoCommand(c *Context, channelId string, message string) *model.CommandResponse
}
var commandProviders = make(map[string]CommandProvider)
func RegisterCommandProvider(newProvider CommandProvider) {
commandProviders[newProvider.GetCommand().Trigger] = newProvider
commandProviders[newProvider.GetTrigger()] = newProvider
}
func GetCommandProvidersProvider(name string) CommandProvider {
@@ -56,7 +58,7 @@ func listCommands(c *Context, w http.ResponseWriter, r *http.Request) {
commands := make([]*model.Command, 0, 32)
seen := make(map[string]bool)
for _, value := range commandProviders {
cpy := *value.GetCommand()
cpy := *value.GetCommand(c)
if cpy.AutoComplete && !seen[cpy.Id] {
cpy.Sanatize()
seen[cpy.Trigger] = true
@@ -87,7 +89,7 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) {
channelId := strings.TrimSpace(props["channelId"])
if len(command) <= 1 || strings.Index(command, "/") != 0 {
c.Err = model.NewLocAppError("executeCommand", "api.command.check_command.start.app_error", nil, "")
c.Err = model.NewLocAppError("executeCommand", "api.command.execute_command.start.app_error", nil, "")
return
}
@@ -147,7 +149,7 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) {
teamCmds := result.Data.([]*model.Command)
for _, cmd := range teamCmds {
if trigger == cmd.Trigger {
l4g.Debug("Executing cmd=" + trigger + " userId=" + c.Session.UserId)
l4g.Debug(fmt.Sprintf(utils.T("api.command.execute_command.debug"), trigger, c.Session.UserId))
p := url.Values{}
p.Set("token", cmd.Token)
@@ -178,18 +180,18 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) {
}
if resp, err := client.Do(req); err != nil {
c.Err = model.NewAppError("command", "Command with a trigger of '"+trigger+"' failed", err.Error())
c.Err = model.NewLocAppError("command", "api.command.execute_command.failed.app_error", map[string]interface{}{"Trigger": trigger}, err.Error())
} else {
if resp.StatusCode == http.StatusOK {
response := model.CommandResponseFromJson(resp.Body)
if response == nil {
c.Err = model.NewAppError("command", "Command with a trigger of '"+trigger+"' returned an empty response", "")
c.Err = model.NewLocAppError("command", "api.command.execute_command.failed_empty.app_error", map[string]interface{}{"Trigger": trigger}, "")
} else {
handleResponse(c, w, response, channelId)
}
} else {
body, _ := ioutil.ReadAll(resp.Body)
c.Err = model.NewAppError("command", "Command with a trigger of '"+trigger+"' returned response "+resp.Status, string(body))
c.Err = model.NewLocAppError("command", "api.command.execute_command.failed_resp.app_error", map[string]interface{}{"Trigger": trigger, "Status": resp.Status}, string(body))
}
}
@@ -200,7 +202,7 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
c.Err = model.NewAppError("command", "Command with a trigger of '"+trigger+"' not found", "")
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) {
@@ -209,14 +211,14 @@ func handleResponse(c *Context, w http.ResponseWriter, response *model.CommandRe
post.ChannelId = channelId
post.Message = response.Text
if _, err := CreatePost(c, post, true); err != nil {
c.Err = model.NewAppError("command", "An error while saving the command response to the channel", "")
c.Err = model.NewLocAppError("command", "api.command.execute_command.save.app_error", nil, "")
}
} else if response.ResponseType == model.COMMAND_RESPONSE_TYPE_EPHEMERAL {
post := &model.Post{}
post.ChannelId = channelId
post.Message = "TODO_EPHEMERAL: " + response.Text
if _, err := CreatePost(c, post, true); err != nil {
c.Err = model.NewAppError("command", "An error while saving the command response to the channel", "")
c.Err = model.NewLocAppError("command", "api.command.execute_command.save.app_error", nil, "")
}
}
@@ -225,14 +227,14 @@ func handleResponse(c *Context, w http.ResponseWriter, response *model.CommandRe
func createCommand(c *Context, w http.ResponseWriter, r *http.Request) {
if !*utils.Cfg.ServiceSettings.EnableCommands {
c.Err = model.NewAppError("createCommand", "Commands have been disabled by the system admin.", "")
c.Err = model.NewLocAppError("createCommand", "api.command.disabled.app_error", nil, "")
c.Err.StatusCode = http.StatusNotImplemented
return
}
if *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations {
if !(c.IsSystemAdmin() || c.IsTeamAdmin()) {
c.Err = model.NewAppError("createCommand", "Integrations have been limited to admins only.", "")
c.Err = model.NewLocAppError("createCommand", "api.command.admin_only.app_error", nil, "")
c.Err.StatusCode = http.StatusForbidden
return
}
@@ -262,14 +264,14 @@ func createCommand(c *Context, w http.ResponseWriter, r *http.Request) {
func listTeamCommands(c *Context, w http.ResponseWriter, r *http.Request) {
if !*utils.Cfg.ServiceSettings.EnableCommands {
c.Err = model.NewAppError("createCommand", "Commands have been disabled by the system admin.", "")
c.Err = model.NewLocAppError("listTeamCommands", "api.command.disabled.app_error", nil, "")
c.Err.StatusCode = http.StatusNotImplemented
return
}
if *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations {
if !(c.IsSystemAdmin() || c.IsTeamAdmin()) {
c.Err = model.NewAppError("createCommand", "Integrations have been limited to admins only.", "")
c.Err = model.NewLocAppError("listTeamCommands", "api.command.admin_only.app_error", nil, "")
c.Err.StatusCode = http.StatusForbidden
return
}
@@ -286,14 +288,14 @@ func listTeamCommands(c *Context, w http.ResponseWriter, r *http.Request) {
func regenCommandToken(c *Context, w http.ResponseWriter, r *http.Request) {
if !*utils.Cfg.ServiceSettings.EnableCommands {
c.Err = model.NewAppError("createCommand", "Commands have been disabled by the system admin.", "")
c.Err = model.NewLocAppError("regenCommandToken", "api.command.disabled.app_error", nil, "")
c.Err.StatusCode = http.StatusNotImplemented
return
}
if *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations {
if !(c.IsSystemAdmin() || c.IsTeamAdmin()) {
c.Err = model.NewAppError("createCommand", "Integrations have been limited to admins only.", "")
c.Err = model.NewLocAppError("regenCommandToken", "api.command.admin_only.app_error", nil, "")
c.Err.StatusCode = http.StatusForbidden
return
}
@@ -318,7 +320,7 @@ func regenCommandToken(c *Context, w http.ResponseWriter, r *http.Request) {
if c.Session.TeamId != cmd.TeamId && c.Session.UserId != cmd.CreatorId && !c.IsTeamAdmin() {
c.LogAudit("fail - inappropriate permissions")
c.Err = model.NewAppError("regenToken", "Inappropriate permissions to regenerate command token", "user_id="+c.Session.UserId)
c.Err = model.NewLocAppError("regenToken", "api.command.regen.app_error", nil, "user_id="+c.Session.UserId)
return
}
}
@@ -335,14 +337,14 @@ func regenCommandToken(c *Context, w http.ResponseWriter, r *http.Request) {
func deleteCommand(c *Context, w http.ResponseWriter, r *http.Request) {
if !*utils.Cfg.ServiceSettings.EnableCommands {
c.Err = model.NewAppError("createCommand", "Commands have been disabled by the system admin.", "")
c.Err = model.NewLocAppError("deleteCommand", "api.command.disabled.app_error", nil, "")
c.Err.StatusCode = http.StatusNotImplemented
return
}
if *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations {
if !(c.IsSystemAdmin() || c.IsTeamAdmin()) {
c.Err = model.NewAppError("createCommand", "Integrations have been limited to admins only.", "")
c.Err = model.NewLocAppError("deleteCommand", "api.command.admin_only.app_error", nil, "")
c.Err.StatusCode = http.StatusForbidden
return
}
@@ -364,7 +366,7 @@ func deleteCommand(c *Context, w http.ResponseWriter, r *http.Request) {
} else {
if c.Session.TeamId != result.Data.(*model.Command).TeamId && c.Session.UserId != result.Data.(*model.Command).CreatorId && !c.IsTeamAdmin() {
c.LogAudit("fail - inappropriate permissions")
c.Err = model.NewAppError("deleteCommand", "Inappropriate permissions to delete command", "user_id="+c.Session.UserId)
c.Err = model.NewLocAppError("deleteCommand", "api.command.delete.app_error", nil, "user_id="+c.Session.UserId)
return
}
}

Просмотреть файл

@@ -17,17 +17,25 @@ var echoSem chan bool
type EchoProvider struct {
}
const (
CMD_ECHO = "echo"
)
func init() {
RegisterCommandProvider(&EchoProvider{})
}
func (me *EchoProvider) GetCommand() *model.Command {
func (me *EchoProvider) GetTrigger() string {
return CMD_ECHO
}
func (me *EchoProvider) GetCommand(c *Context) *model.Command {
return &model.Command{
Trigger: "echo",
Trigger: CMD_ECHO,
AutoComplete: true,
AutoCompleteDesc: "Echo back text from your account",
AutoCompleteHint: "\"message\" [delay in seconds]",
DisplayName: "echo",
AutoCompleteDesc: c.T("api.command_echo.desc"),
AutoCompleteHint: c.T("api.command_echo.hint"),
DisplayName: c.T("api.command_echo.name"),
}
}
@@ -51,7 +59,7 @@ func (me *EchoProvider) DoCommand(c *Context, channelId string, message string)
}
if delay > 10000 {
return &model.CommandResponse{Text: "Delays must be under 10000 seconds", ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
return &model.CommandResponse{Text: c.T("api.command_echo.delay.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
}
if echoSem == nil {
@@ -60,7 +68,7 @@ func (me *EchoProvider) DoCommand(c *Context, channelId string, message string)
}
if len(echoSem) >= maxThreads {
return &model.CommandResponse{Text: "High volume of echo request, cannot process request", ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
return &model.CommandResponse{Text: c.T("api.command_echo.high_volume.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
}
echoSem <- true
@@ -73,7 +81,7 @@ func (me *EchoProvider) DoCommand(c *Context, channelId string, message string)
time.Sleep(time.Duration(delay) * time.Second)
if _, err := CreatePost(c, post, true); err != nil {
l4g.Error("Unable to create /echo post, err=%v", err)
l4g.Error(c.T("api.command_echo.create.app_error"), err)
}
}()

Просмотреть файл

@@ -10,23 +10,31 @@ import (
type JoinProvider struct {
}
const (
CMD_JOIN = "join"
)
func init() {
RegisterCommandProvider(&JoinProvider{})
}
func (me *JoinProvider) GetCommand() *model.Command {
func (me *JoinProvider) GetTrigger() string {
return CMD_JOIN
}
func (me *JoinProvider) GetCommand(c *Context) *model.Command {
return &model.Command{
Trigger: "join",
Trigger: CMD_JOIN,
AutoComplete: true,
AutoCompleteDesc: "Join the open channel",
AutoCompleteHint: "[channel-name]",
DisplayName: "join",
AutoCompleteDesc: c.T("api.command_join.desc"),
AutoCompleteHint: c.T("api.command_join.hint"),
DisplayName: c.T("api.command_join.name"),
}
}
func (me *JoinProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse {
if result := <-Srv.Store.Channel().GetMoreChannels(c.Session.TeamId, c.Session.UserId); result.Err != nil {
return &model.CommandResponse{Text: "An error occured while listing channels.", ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
return &model.CommandResponse{Text: c.T("api.command_join.list.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
} else {
channels := result.Data.(*model.ChannelList)
@@ -35,20 +43,20 @@ func (me *JoinProvider) DoCommand(c *Context, channelId string, message string)
if v.Name == message {
if v.Type == model.CHANNEL_DIRECT {
return &model.CommandResponse{Text: "An error occured while joining the channel.", ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
return &model.CommandResponse{Text: c.T("api.command_join.fail.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
}
JoinChannel(c, v.Id, "")
if c.Err != nil {
c.Err = nil
return &model.CommandResponse{Text: "An error occured while joining the channel.", ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
return &model.CommandResponse{Text: c.T("api.command_join.fail.app_error"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
}
return &model.CommandResponse{GotoLocation: c.GetTeamURL() + "/channels/" + v.Name, Text: "Joined channel.", ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
return &model.CommandResponse{GotoLocation: c.GetTeamURL() + "/channels/" + v.Name, Text: c.T("api.command_join.success"), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL}
}
}
}
return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: "We couldn't find the channel"}
return &model.CommandResponse{ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: c.T("api.command_join.missing.app_error")}
}

Просмотреть файл

@@ -52,6 +52,10 @@ var usage = `Mattermost load testing commands to help configure the system
`
const (
CMD_LOADTEST = "loadtest"
)
type LoadTestProvider struct {
}
@@ -61,9 +65,13 @@ func init() {
}
}
func (me *LoadTestProvider) GetCommand() *model.Command {
func (me *LoadTestProvider) GetTrigger() string {
return CMD_LOADTEST
}
func (me *LoadTestProvider) GetCommand(c *Context) *model.Command {
return &model.Command{
Trigger: "loadtest",
Trigger: CMD_LOADTEST,
AutoComplete: false,
AutoCompleteDesc: "Debug Load Testing",
AutoCompleteHint: "help",
@@ -73,10 +81,10 @@ func (me *LoadTestProvider) GetCommand() *model.Command {
func (me *LoadTestProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse {
// This command is only available when EnableTesting is true
// if !utils.Cfg.ServiceSettings.EnableTesting {
// return &model.CommandResponse{}
// }
//This command is only available when EnableTesting is true
if !utils.Cfg.ServiceSettings.EnableTesting {
return &model.CommandResponse{}
}
if strings.HasPrefix(message, "setup") {
return me.SetupCommand(c, channelId, message)

Просмотреть файл

@@ -10,20 +10,28 @@ import (
type LogoutProvider struct {
}
const (
CMD_LOGOUT = "logout"
)
func init() {
RegisterCommandProvider(&LogoutProvider{})
}
func (me *LogoutProvider) GetCommand() *model.Command {
func (me *LogoutProvider) GetTrigger() string {
return CMD_LOGOUT
}
func (me *LogoutProvider) GetCommand(c *Context) *model.Command {
return &model.Command{
Trigger: "logout",
Trigger: CMD_LOGOUT,
AutoComplete: true,
AutoCompleteDesc: "Logout",
AutoCompleteDesc: c.T("api.command_logout.desc"),
AutoCompleteHint: "",
DisplayName: "logout",
DisplayName: c.T("api.command_logout.name"),
}
}
func (me *LogoutProvider) DoCommand(c *Context, channelId string, message string) *model.CommandResponse {
return &model.CommandResponse{GotoLocation: "/logout", ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: "Logging out..."}
return &model.CommandResponse{GotoLocation: "/logout", ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, Text: c.T("api.command_logout.success_message")}
}

Просмотреть файл

@@ -10,17 +10,25 @@ import (
type MeProvider struct {
}
const (
CMD_ME = "me"
)
func init() {
RegisterCommandProvider(&MeProvider{})
}
func (me *MeProvider) GetCommand() *model.Command {
func (me *MeProvider) GetTrigger() string {
return CMD_ME
}
func (me *MeProvider) GetCommand(c *Context) *model.Command {
return &model.Command{
Trigger: "me",
Trigger: CMD_ME,
AutoComplete: true,
AutoCompleteDesc: "Do an action",
AutoCompleteHint: "[message]",
DisplayName: "me",
AutoCompleteDesc: c.T("api.command_me.desc"),
AutoCompleteHint: c.T("api.command_me.hint"),
DisplayName: c.T("api.command_me.name"),
}
}

Просмотреть файл

@@ -10,17 +10,25 @@ import (
type ShrugProvider struct {
}
const (
CMD_SHRUG = "shrug"
)
func init() {
RegisterCommandProvider(&ShrugProvider{})
}
func (me *ShrugProvider) GetCommand() *model.Command {
func (me *ShrugProvider) GetTrigger() string {
return CMD_SHRUG
}
func (me *ShrugProvider) GetCommand(c *Context) *model.Command {
return &model.Command{
Trigger: "shrug",
Trigger: CMD_SHRUG,
AutoComplete: true,
AutoCompleteDesc: `Adds ¯\_(ツ)_/¯ to your message`,
AutoCompleteHint: "[message]",
DisplayName: "shrug",
AutoCompleteDesc: c.T("api.command_shrug.desc"),
AutoCompleteHint: c.T("api.command_shrug.hint"),
DisplayName: c.T("api.command_shrug.name"),
}
}

Просмотреть файл

@@ -34,7 +34,7 @@ func createIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) {
if *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations {
if !(c.IsSystemAdmin() || c.IsTeamAdmin()) {
c.Err = model.NewAppError("createCommand", "Integrations have been limited to admins only.", "")
c.Err = model.NewLocAppError("createIncomingHook", "api.command.admin_only.app_error", nil, "")
c.Err.StatusCode = http.StatusForbidden
return
}
@@ -89,7 +89,7 @@ func deleteIncomingHook(c *Context, w http.ResponseWriter, r *http.Request) {
if *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations {
if !(c.IsSystemAdmin() || c.IsTeamAdmin()) {
c.Err = model.NewAppError("createCommand", "Integrations have been limited to admins only.", "")
c.Err = model.NewLocAppError("deleteIncomingHook", "api.command.admin_only.app_error", nil, "")
c.Err.StatusCode = http.StatusForbidden
return
}
@@ -134,7 +134,7 @@ func getIncomingHooks(c *Context, w http.ResponseWriter, r *http.Request) {
if *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations {
if !(c.IsSystemAdmin() || c.IsTeamAdmin()) {
c.Err = model.NewAppError("createCommand", "Integrations have been limited to admins only.", "")
c.Err = model.NewLocAppError("getIncomingHooks", "api.command.admin_only.app_error", nil, "")
c.Err.StatusCode = http.StatusForbidden
return
}
@@ -158,7 +158,7 @@ func createOutgoingHook(c *Context, w http.ResponseWriter, r *http.Request) {
if *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations {
if !(c.IsSystemAdmin() || c.IsTeamAdmin()) {
c.Err = model.NewAppError("createCommand", "Integrations have been limited to admins only.", "")
c.Err = model.NewLocAppError("createOutgoingHook", "api.command.admin_only.app_error", nil, "")
c.Err.StatusCode = http.StatusForbidden
return
}
@@ -222,7 +222,7 @@ func getOutgoingHooks(c *Context, w http.ResponseWriter, r *http.Request) {
if *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations {
if !(c.IsSystemAdmin() || c.IsTeamAdmin()) {
c.Err = model.NewAppError("createCommand", "Integrations have been limited to admins only.", "")
c.Err = model.NewLocAppError("getOutgoingHooks", "api.command.admin_only.app_error", nil, "")
c.Err.StatusCode = http.StatusForbidden
return
}
@@ -246,7 +246,7 @@ func deleteOutgoingHook(c *Context, w http.ResponseWriter, r *http.Request) {
if *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations {
if !(c.IsSystemAdmin() || c.IsTeamAdmin()) {
c.Err = model.NewAppError("createCommand", "Integrations have been limited to admins only.", "")
c.Err = model.NewLocAppError("deleteOutgoingHook", "api.command.admin_only.app_error", nil, "")
c.Err.StatusCode = http.StatusForbidden
return
}
@@ -291,7 +291,7 @@ func regenOutgoingHookToken(c *Context, w http.ResponseWriter, r *http.Request)
if *utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations {
if !(c.IsSystemAdmin() || c.IsTeamAdmin()) {
c.Err = model.NewAppError("createCommand", "Integrations have been limited to admins only.", "")
c.Err = model.NewLocAppError("regenOutgoingHookToken", "api.command.admin_only.app_error", nil, "")
c.Err.StatusCode = http.StatusForbidden
return
}

Просмотреть файл

@@ -243,122 +243,142 @@
"id": "api.channel.update_channel.tried.app_error",
"translation": "Tried to perform an invalid update of the default channel {{.Channel}}"
},
{
"id": "api.command.check_command.start.app_error",
"translation": "Command must start with /"
},
{
"id": "api.command.echo_command.create.error",
"translation": "Unable to create /echo post, err=%v"
},
{
"id": "api.command.echo_command.description",
"translation": "Echo back text from your account, /echo \"message\" [delay in seconds]"
},
{
"id": "api.command.echo_command.high_volume.app_error",
"translation": "High volume of echo request, cannot process request"
},
{
"id": "api.command.echo_command.under.app_error",
"translation": "Delays must be under 10000 seconds"
},
{
"id": "api.command.init.debug",
"translation": "Initializing command api routes"
},
{
"id": "api.command.load_test_channels_command.channel.description",
"translation": "Add a specified number of random channels to current team <MinChannels> <MaxChannels>"
"id": "api.command.execute_command.start.app_error",
"translation": "No command trigger found"
},
{
"id": "api.command.load_test_channels_command.fuzz.description",
"translation": "Add a specified number of random channels with fuzz text to current team <Min Channels> <Max Channels>"
"id": "api.command.execute_command.debug",
"translation": "Executing cmd=%v userId=%v"
},
{
"id": "api.command.load_test_command.description",
"translation": "Debug Load Testing"
"id": "api.command.execute_command.failed.app_error",
"translation": "Command with a trigger of '{{.Trigger}}' failed"
},
{
"id": "api.command.load_test_posts_command.fuzz.description",
"translation": "Add some random posts with fuzz text to current channel <Min Posts> <Max Posts> <Min Images> <Max Images>"
"id": "api.command.execute_command.failed_empty.app_error",
"translation": "Command with a trigger of '{{.Trigger}}' returned an empty response"
},
{
"id": "api.command.load_test_posts_command.posts.description",
"translation": "Add some random posts to current channel <Min Posts> <Max Posts> <Min Images> <Max Images>"
"id": "api.command.execute_command.failed_resp.app_error",
"translation": "Command with a trigger of '{{.Trigger}}' returned response {{.Status}}"
},
{
"id": "api.command.load_test_setup_command.create.error",
"translation": "Failed to create testing environment"
"id": "api.command.execute_command.not_found.app_error",
"translation": "Command with a trigger of '{{.Trigger}}' not found"
},
{
"id": "api.command.load_test_setup_command.created.info",
"translation": "Team Created: %v"
"id": "api.command.execute_command.save.app_error",
"translation": "An error while saving the command response to the channel"
},
{
"id": "api.command.load_test_setup_command.description",
"translation": "Creates a testing environment in current team. [teams] [fuzz] <Num Channels> <Num Users> <NumPosts>"
"id": "api.command.disabled.app_error",
"translation": "Commands have been disabled by the system admin."
},
{
"id": "api.command.load_test_setup_command.login.info",
"translation": "\t User to login: %v, %v"
"id": "api.command.admin_only.app_error",
"translation": "Integrations have been limited to admins only."
},
{
"id": "api.command.load_test_url_command.create.error",
"translation": "Unable to create post, err=%v"
"id": "api.command.regen.app_error",
"translation": "Inappropriate permissions to regenerate command token"
},
{
"id": "api.command.load_test_url_command.description",
"translation": "Add a post containing the text from a given url to current channel <Url>"
"id": "api.command.delete.app_error",
"translation": "Inappropriate permissions to delete command"
},
{
"id": "api.command.load_test_url_command.file.app_error",
"translation": "Unable to get file"
"id": "api.command_echo.desc",
"translation": "Echo back text from your account"
},
{
"id": "api.command.load_test_url_command.reading.app_error",
"translation": "Encountered error reading file"
"id": "api.command_echo.hint",
"translation": "'message' [delay in seconds]"
},
{
"id": "api.command.load_test_url_command.url.app_error",
"translation": "Command must contain a url"
"id": "api.command_echo.name",
"translation": "echo"
},
{
"id": "api.command.load_test_users_command.fuzz.description",
"translation": "Add a specified number of random users with fuzz text to current team <Min Users> <Max Users>"
"id": "api.command_echo.delay.app_error",
"translation": "Delays must be under 10000 seconds"
},
{
"id": "api.command.load_test_users_command.users.description",
"translation": "Add a specified number of random users to current team <Min Users> <Max Users>"
"id": "api.command_echo.high_volume.app_error",
"translation": "High volume of echo request, cannot process request"
},
{
"id": "api.command.logout_command.description",
"translation": "Logout"
"id": "api.command_echo.create.app_error",
"translation": "Unable to create /echo post, err=%v"
},
{
"id": "api.command.me_command.create.error",
"translation": "Unable to create /me post post, err=%v"
},
{
"id": "api.command.me_command.description",
"translation": "Do an action, /me [message]"
},
{
"id": "api.command.no_implemented.app_error",
"translation": "Command not implemented"
},
{
"id": "api.command.shrug_command.create.error",
"translation": "Unable to create /shrug post post, err=%v"
},
{
"id": "api.command.shrug_command.description",
"translation": "Adds ¯\\_(ツ)_/¯ to your message, /shrug [message]"
},
{
"id": "api.commmand.join_command.description",
"id": "api.command_join.desc",
"translation": "Join the open channel"
},
{
"id": "api.command_join.hint",
"translation": "[channel-name]"
},
{
"id": "api.command_join.name",
"translation": "join"
},
{
"id": "api.command_join.list.app_error",
"translation": "An error occured while listing channels."
},
{
"id": "api.command_join.fail.app_error",
"translation": "An error occured while joining the channel."
},
{
"id": "api.command_join.success",
"translation": "Joined channel."
},
{
"id": "api.command_join.missing.app_error",
"translation": "We couldn't find the channel"
},
{
"id": "api.command_logout.desc",
"translation": "Logout of Mattermost"
},
{
"id": "api.command_logout.name",
"translation": "logout"
},
{
"id": "api.command_logout.success_message",
"translation": "Logging out..."
},
{
"id": "api.command_me.desc",
"translation": "Do an action"
},
{
"id": "api.command_me.hint",
"translation": "[message]"
},
{
"id": "api.command_me.name",
"translation": "me"
},
{
"id": "api.command_shrug.desc",
"translation": "Adds ¯\\_(ツ)_/¯ to your message"
},
{
"id": "api.command_shrug.hint",
"translation": "[message]"
},
{
"id": "api.command_shrug.name",
"translation": "shrug"
},
{
"id": "api.context.404.app_error",
"translation": "Sorry, we could not find the page."
@@ -1775,6 +1795,46 @@
"id": "model.channel.is_valid.2_or_more.app_error",
"translation": "Name must be 2 or more lowercase alphanumeric characters"
},
{
"id": "model.command.is_valid.id.app_error",
"translation": "Invalid Id"
},
{
"id": "model.command.is_valid.token.app_error",
"translation": "Invalid token"
},
{
"id": "model.command.is_valid.create_at.app_error",
"translation": "Create at must be a valid time"
},
{
"id": "model.command.is_valid.update_at.app_error",
"translation": "Update at must be a valid time"
},
{
"id": "model.command.is_valid.user_id.app_error",
"translation": "Invalid user id"
},
{
"id": "model.command.is_valid.team_id.app_error",
"translation": "Invalid team id"
},
{
"id": "model.command.is_valid.trigger.app_error",
"translation": "Invalid trigger"
},
{
"id": "model.command.is_valid.url.app_error",
"translation": "Invalid url"
},
{
"id": "model.command.is_valid.url_http.app_error",
"translation": "Invalid URL. Must be a valid URL and start with http:// or https://"
},
{
"id": "model.command.is_valid.method.app_error",
"translation": "Invalid Method"
},
{
"id": "model.channel.is_valid.create_at.app_error",
"translation": "Create at must be a valid time"
@@ -2343,6 +2403,34 @@
"id": "store.sql_audit.save.saving.app_error",
"translation": "We encountered an error saving the audit"
},
{
"id": "store.sql_command.save.saving_overwrite.app_error",
"translation": "You cannot overwrite an existing Command"
},
{
"id": "store.sql_command.save.saving.app_error",
"translation": "We couldn't save the Command"
},
{
"id": "store.sql_command.save.get.app_error",
"translation": "We couldn't get the command"
},
{
"id": "store.sql_command.save.get_team.app_error",
"translation": "We couldn't get the commands"
},
{
"id": "store.sql_command.save.delete.app_error",
"translation": "We couldn't delete the command"
},
{
"id": "store.sql_command.save.delete_perm.app_error",
"translation": "We couldn't delete the command"
},
{
"id": "store.sql_command.save.update.app_error",
"translation": "We couldn't update the command"
},
{
"id": "store.sql_channel.analytics_type_count.app_error",
"translation": "We couldn't get channel type counts"

Просмотреть файл

@@ -243,122 +243,6 @@
"id": "api.channel.update_channel.tried.app_error",
"translation": "Intento de realizar una actualización inválida al canal predeterminado {{.Channel}}"
},
{
"id": "api.command.check_command.start.app_error",
"translation": "El comando debe comenzar con /"
},
{
"id": "api.command.echo_command.create.error",
"translation": "No se puede crear /echo mensaje, err=%v"
},
{
"id": "api.command.echo_command.description",
"translation": "Echo del texto desde tu cuenta, /echo \"mensaje\" [retraso en segundos]"
},
{
"id": "api.command.echo_command.high_volume.app_error",
"translation": "Volumen alto de solicitudes echo, no se puede procesar la solicitud"
},
{
"id": "api.command.echo_command.under.app_error",
"translation": "El retraso debe ser menor a 10000 segundos"
},
{
"id": "api.command.init.debug",
"translation": "Inicializando rutas del API para los comandos"
},
{
"id": "api.command.load_test_channels_command.channel.description",
"translation": "Agrega un número específico de canales aleatorios al equipo actual <MinChannels> <MaxChannels>"
},
{
"id": "api.command.load_test_channels_command.fuzz.description",
"translation": "Agrega un número específico de canales aleatorios con el texto fuzz al equipo actual <Min Channels> <Max Channels>"
},
{
"id": "api.command.load_test_command.description",
"translation": "Depurar pruebas de carga"
},
{
"id": "api.command.load_test_posts_command.fuzz.description",
"translation": "Agrega algunos mensajes aleatorios con el texto fuzz al canal actual <Min Mensajes> <Max Mensajes> <Min Images> <Max Imágenes>"
},
{
"id": "api.command.load_test_posts_command.posts.description",
"translation": "Agrega algunos mensajes aleatorios al canal actual <Min Mensajes> <Max Mensajes> <Min Images> <Max Imágenes>"
},
{
"id": "api.command.load_test_setup_command.create.error",
"translation": "Falla al crear el entorno de pruebas"
},
{
"id": "api.command.load_test_setup_command.created.info",
"translation": "Equipo Creado: %v"
},
{
"id": "api.command.load_test_setup_command.description",
"translation": "Crea un entorno de prueba para el equipo actual. [equipos] [fuzz] <Cant Canales> <Cant Usuarios> <Num Mensajes>"
},
{
"id": "api.command.load_test_setup_command.login.info",
"translation": "\t Usuario que inicia sesión: %v, %v"
},
{
"id": "api.command.load_test_url_command.create.error",
"translation": "No se pudo crear el mensaje, err=%v"
},
{
"id": "api.command.load_test_url_command.description",
"translation": "Agraga un mensaje que contiene el texto de un url dado al canal actual <Url>"
},
{
"id": "api.command.load_test_url_command.file.app_error",
"translation": "No se puede obtener el archivo"
},
{
"id": "api.command.load_test_url_command.reading.app_error",
"translation": "Se encontró un error leyendo el archivo"
},
{
"id": "api.command.load_test_url_command.url.app_error",
"translation": "El comando debe contener un url"
},
{
"id": "api.command.load_test_users_command.fuzz.description",
"translation": "Agraga un número específico de usuarios aleatorios con el texto fuzz al equipo actual <Min Users> <Max Users>"
},
{
"id": "api.command.load_test_users_command.users.description",
"translation": "Agrega un número específico de usuarios aleatorios al equipo actual <Min Users> <Max Users>"
},
{
"id": "api.command.logout_command.description",
"translation": "Cerrar sesión"
},
{
"id": "api.command.me_command.create.error",
"translation": "No se pudo crear el mensaje /me mensaje, err=%v"
},
{
"id": "api.command.me_command.description",
"translation": "Realiza una acción, /me [mensaje]"
},
{
"id": "api.command.no_implemented.app_error",
"translation": "Comando no implementado"
},
{
"id": "api.command.shrug_command.create.error",
"translation": "No se pudo crear el mensaje /shrug mensaje, err=%v"
},
{
"id": "api.command.shrug_command.description",
"translation": "Agrega ¯\\_(ツ)_/¯ a tu mensaje, /shrug [mensaje]"
},
{
"id": "api.commmand.join_command.description",
"translation": "Unirme al canal abierto"
},
{
"id": "api.context.404.app_error",
"translation": "Lo sentimos, pero no pudimos encontrar la página."

Просмотреть файл

@@ -75,43 +75,43 @@ func CommandListFromJson(data io.Reader) []*Command {
func (o *Command) IsValid() *AppError {
if len(o.Id) != 26 {
return NewAppError("Command.IsValid", "Invalid Id", "")
return NewLocAppError("Command.IsValid", "model.command.is_valid.id.app_error", nil, "")
}
if len(o.Token) != 26 {
return NewAppError("Command.IsValid", "Invalid token", "")
return NewLocAppError("Command.IsValid", "model.command.is_valid.token.app_error", nil, "")
}
if o.CreateAt == 0 {
return NewAppError("Command.IsValid", "Create at must be a valid time", "id="+o.Id)
return NewLocAppError("Command.IsValid", "model.command.is_valid.create_at.app_error", nil, "")
}
if o.UpdateAt == 0 {
return NewAppError("Command.IsValid", "Update at must be a valid time", "id="+o.Id)
return NewLocAppError("Command.IsValid", "model.command.is_valid.update_at.app_error", nil, "")
}
if len(o.CreatorId) != 26 {
return NewAppError("Command.IsValid", "Invalid user id", "")
return NewLocAppError("Command.IsValid", "model.command.is_valid.user_id.app_error", nil, "")
}
if len(o.TeamId) != 26 {
return NewAppError("Command.IsValid", "Invalid team id", "")
return NewLocAppError("Command.IsValid", "model.command.is_valid.team_id.app_error", nil, "")
}
if len(o.Trigger) > 1024 {
return NewAppError("Command.IsValid", "Invalid trigger", "")
return NewLocAppError("Command.IsValid", "model.command.is_valid.trigger.app_error", nil, "")
}
if len(o.URL) == 0 || len(o.URL) > 1024 {
return NewAppError("Command.IsValid", "Invalid url", "")
return NewLocAppError("Command.IsValid", "model.command.is_valid.url.app_error", nil, "")
}
if !IsValidHttpUrl(o.URL) {
return NewAppError("Command.IsValid", "Invalid URL. Must be a valid URL and start with http:// or https://", "")
return NewLocAppError("Command.IsValid", "model.command.is_valid.url_http.app_error", nil, "")
}
if !(o.Method == COMMAND_METHOD_GET || o.Method == COMMAND_METHOD_POST) {
return NewAppError("Command.IsValid", "Invalid Method", "")
return NewLocAppError("Command.IsValid", "model.command.is_valid.method.app_error", nil, "")
}
return nil

Просмотреть файл

@@ -47,8 +47,7 @@ func (s SqlCommandStore) Save(command *model.Command) StoreChannel {
result := StoreResult{}
if len(command.Id) > 0 {
result.Err = model.NewAppError("SqlCommandStore.Save",
"You cannot overwrite an existing Command", "id="+command.Id)
result.Err = model.NewLocAppError("SqlCommandStore.Save", "store.sql_command.save.saving_overwrite.app_error", nil, "id="+command.Id)
storeChannel <- result
close(storeChannel)
return
@@ -62,7 +61,7 @@ func (s SqlCommandStore) Save(command *model.Command) StoreChannel {
}
if err := s.GetMaster().Insert(command); err != nil {
result.Err = model.NewAppError("SqlCommandStore.Save", "We couldn't save the Command", "id="+command.Id+", "+err.Error())
result.Err = model.NewLocAppError("SqlCommandStore.Save", "store.sql_command.save.saving.app_error", nil, "id="+command.Id+", "+err.Error())
} else {
result.Data = command
}
@@ -83,7 +82,7 @@ func (s SqlCommandStore) Get(id string) StoreChannel {
var command model.Command
if err := s.GetReplica().SelectOne(&command, "SELECT * FROM Commands WHERE Id = :Id AND DeleteAt = 0", map[string]interface{}{"Id": id}); err != nil {
result.Err = model.NewAppError("SqlCommandStore.Get", "We couldn't get the command", "id="+id+", err="+err.Error())
result.Err = model.NewLocAppError("SqlCommandStore.Get", "store.sql_command.save.get.app_error", nil, "id="+id+", err="+err.Error())
}
result.Data = &command
@@ -104,7 +103,7 @@ func (s SqlCommandStore) GetByTeam(teamId string) StoreChannel {
var commands []*model.Command
if _, err := s.GetReplica().Select(&commands, "SELECT * FROM Commands WHERE TeamId = :TeamId AND DeleteAt = 0", map[string]interface{}{"TeamId": teamId}); err != nil {
result.Err = model.NewAppError("SqlCommandStore.GetByTeam", "We couldn't get the commands", "teamId="+teamId+", err="+err.Error())
result.Err = model.NewLocAppError("SqlCommandStore.GetByTeam", "store.sql_command.save.get_team.app_error", nil, "teamId="+teamId+", err="+err.Error())
}
result.Data = commands
@@ -124,7 +123,7 @@ func (s SqlCommandStore) Delete(commandId string, time int64) StoreChannel {
_, err := s.GetMaster().Exec("Update Commands SET DeleteAt = :DeleteAt, UpdateAt = :UpdateAt WHERE Id = :Id", map[string]interface{}{"DeleteAt": time, "UpdateAt": time, "Id": commandId})
if err != nil {
result.Err = model.NewAppError("SqlCommandStore.Delete", "We couldn't delete the command", "id="+commandId+", err="+err.Error())
result.Err = model.NewLocAppError("SqlCommandStore.Delete", "store.sql_command.save.delete.app_error", nil, "id="+commandId+", err="+err.Error())
}
storeChannel <- result
@@ -142,7 +141,7 @@ func (s SqlCommandStore) PermanentDeleteByUser(userId string) StoreChannel {
_, err := s.GetMaster().Exec("DELETE FROM Commands WHERE CreatorId = :UserId", map[string]interface{}{"UserId": userId})
if err != nil {
result.Err = model.NewAppError("SqlCommandStore.DeleteByUser", "We couldn't delete the command", "id="+userId+", err="+err.Error())
result.Err = model.NewLocAppError("SqlCommandStore.DeleteByUser", "store.sql_command.save.delete_perm.app_error", nil, "id="+userId+", err="+err.Error())
}
storeChannel <- result
@@ -161,7 +160,7 @@ func (s SqlCommandStore) Update(hook *model.Command) StoreChannel {
hook.UpdateAt = model.GetMillis()
if _, err := s.GetMaster().Update(hook); err != nil {
result.Err = model.NewAppError("SqlCommandStore.Update", "We couldn't update the command", "id="+hook.Id+", "+err.Error())
result.Err = model.NewLocAppError("SqlCommandStore.Update", "store.sql_command.save.update.app_error", nil, "id="+hook.Id+", "+err.Error())
} else {
result.Data = hook
}