summaryrefslogtreecommitdiffstats
path: root/app/command.go
diff options
context:
space:
mode:
authorJesse Hallam <jesse.hallam@gmail.com>2018-05-14 13:24:22 -0400
committerJoram Wilander <jwawilander@gmail.com>2018-05-14 13:24:22 -0400
commita1656dffa98fbc8865e476b214e4e0c562547d39 (patch)
treee50ba28d9eaf21640a6bfcd55c0fb237030911c5 /app/command.go
parent6a9aa855d1c862e4d39f8c00c6b7425405e7a612 (diff)
downloadchat-a1656dffa98fbc8865e476b214e4e0c562547d39.tar.gz
chat-a1656dffa98fbc8865e476b214e4e0c562547d39.tar.bz2
chat-a1656dffa98fbc8865e476b214e4e0c562547d39.zip
MM-10201: querystring for get slash commands (#8779)
* pass GET slash command payloads through query string Previously, both GET and POST requests received the payload via the body, but this was incorrect for GET requests. Now, the payloads for GET requests is sent via the query string. * reorder tests for clarity * switch command tests to use httptest servers * restore original test command endpoints
Diffstat (limited to 'app/command.go')
-rw-r--r--app/command.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/app/command.go b/app/command.go
index 796d656a7..92c35865a 100644
--- a/app/command.go
+++ b/app/command.go
@@ -230,12 +230,14 @@ func (a *App) ExecuteCommand(args *model.CommandArgs) (*model.CommandResponse, *
p.Set("response_url", args.SiteURL+"/hooks/commands/"+hook.Id)
}
- method := "POST"
+ var req *http.Request
if cmd.Method == model.COMMAND_METHOD_GET {
- method = "GET"
+ req, _ = http.NewRequest(http.MethodGet, cmd.URL, nil)
+ req.URL.RawQuery = p.Encode()
+ } else {
+ req, _ = http.NewRequest(http.MethodPost, cmd.URL, strings.NewReader(p.Encode()))
}
- req, _ := http.NewRequest(method, cmd.URL, strings.NewReader(p.Encode()))
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", "Token "+cmd.Token)
if cmd.Method == model.COMMAND_METHOD_POST {