From 0ed94b0c3852752e50453af819d8f7a8da17137e Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Tue, 12 Mar 2024 18:01:38 -0700 Subject: [PATCH] Fix task slash commands being run. (#1889) * Fix task slash commands being run. * Style fix. --- server/api/playbook_runs.go | 7 +++++++ webapp/src/client.ts | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/server/api/playbook_runs.go b/server/api/playbook_runs.go index 6a9636b94a..6af5a7a377 100644 --- a/server/api/playbook_runs.go +++ b/server/api/playbook_runs.go @@ -3,6 +3,7 @@ package api import ( "encoding/json" "fmt" + "io" "net/http" "net/url" "sort" @@ -1311,6 +1312,12 @@ func (h *PlaybookRunHandler) itemRun(c *Context, w http.ResponseWriter, r *http. } userID := r.Header.Get("Mattermost-User-ID") + // Check the body is empty + if _, err := r.Body.Read(make([]byte, 1)); err != io.EOF { + h.HandleErrorWithCode(w, c.logger, http.StatusBadRequest, "request body must be empty", nil) + return + } + triggerID, err := h.playbookRunService.RunChecklistItemSlashCommand(playbookRunID, userID, checklistNum, itemNum) if err != nil { h.HandleError(w, c.logger, err) diff --git a/webapp/src/client.ts b/webapp/src/client.ts index 2141753d88..172166e937 100644 --- a/webapp/src/client.ts +++ b/webapp/src/client.ts @@ -699,7 +699,7 @@ export const doGet = async (url: string) => { return data; }; -export const doPost = async (url: string, body = {}) => { +export const doPost = async (url: string, body: any = undefined) => { const {data} = await doFetchWithResponse(url, { method: 'POST', body, @@ -708,7 +708,7 @@ export const doPost = async (url: string, body = {}) => { return data; }; -export const doPut = async (url: string, body = {}) => { +export const doPut = async (url: string, body: any = undefined) => { const {data} = await doFetchWithResponse(url, { method: 'PUT', body,