summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lu <david.lu@hotmail.com>2016-07-14 10:05:25 -0400
committerJoram Wilander <jwawilander@gmail.com>2016-07-14 10:05:25 -0400
commit8e810bc2ebb743717b5b0fc4541fcd3b2565966c (patch)
treef9ad319c1ed0c0dc8683b134965a986734dbbf90
parent9b9facd3d21a7ab341dd6d80fd8b53fb852ae036 (diff)
downloadchat-8e810bc2ebb743717b5b0fc4541fcd3b2565966c.tar.gz
chat-8e810bc2ebb743717b5b0fc4541fcd3b2565966c.tar.bz2
chat-8e810bc2ebb743717b5b0fc4541fcd3b2565966c.zip
PLT-3153 Converted slash command triggers to lowercase on save (#3577)
* Converted slash command triggers to lowercase on save * Made slash commands case insensitive
-rw-r--r--api/command.go2
-rw-r--r--webapp/actions/channel_actions.jsx6
-rw-r--r--webapp/components/integrations/components/add_command.jsx2
3 files changed, 8 insertions, 2 deletions
diff --git a/api/command.go b/api/command.go
index b4c9bb616..1e58308ad 100644
--- a/api/command.go
+++ b/api/command.go
@@ -106,6 +106,7 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) {
parts := strings.Split(command, " ")
trigger := parts[0][1:]
+ trigger = strings.ToLower(trigger)
message := strings.Join(parts[1:], " ")
provider := GetCommandProvider(trigger)
@@ -286,6 +287,7 @@ func createCommand(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
+ cmd.Trigger = strings.ToLower(cmd.Trigger)
cmd.CreatorId = c.Session.UserId
cmd.TeamId = c.TeamId
diff --git a/webapp/actions/channel_actions.jsx b/webapp/actions/channel_actions.jsx
index f8bc61538..c02568043 100644
--- a/webapp/actions/channel_actions.jsx
+++ b/webapp/actions/channel_actions.jsx
@@ -24,7 +24,11 @@ export function goToChannel(channel) {
}
export function executeCommand(channelId, message, suggest, success, error) {
- Client.executeCommand(channelId, message, suggest, success, error);
+ let msg = message;
+
+ msg = msg.substring(0, msg.indexOf(' ')).toLowerCase() + msg.substring(msg.indexOf(' '), msg.length);
+
+ Client.executeCommand(channelId, msg, suggest, success, error);
}
export function setChannelAsRead(channelIdParam) {
diff --git a/webapp/components/integrations/components/add_command.jsx b/webapp/components/integrations/components/add_command.jsx
index e72670e47..cf563875b 100644
--- a/webapp/components/integrations/components/add_command.jsx
+++ b/webapp/components/integrations/components/add_command.jsx
@@ -72,7 +72,7 @@ export default class AddCommand extends React.Component {
const command = {
display_name: this.state.displayName,
description: this.state.description,
- trigger: this.state.trigger.trim(),
+ trigger: this.state.trigger.trim().toLowerCase(),
url: this.state.url.trim(),
method: this.state.method,
username: this.state.username,