2
0

🐛 (webhook) Don't send body when GET method is used

This commit is contained in:
Baptiste Arnaud
2022-09-11 11:42:25 +02:00
parent d696f551c3
commit 4a04d1ccba
2 changed files with 16 additions and 15 deletions

View File

@@ -132,13 +132,15 @@ export const executeWebhook =
resultValues, resultValues,
groupId, groupId,
}) })
const { data: body, isJson } = bodyContent const { data: body, isJson } =
? safeJsonParse( bodyContent && webhook.method !== HttpMethod.GET
parseVariables(variables, { ? safeJsonParse(
escapeForJson: !checkIfBodyIsAVariable(bodyContent), parseVariables(variables, {
})(bodyContent) escapeForJson: !checkIfBodyIsAVariable(bodyContent),
) })(bodyContent)
: { data: undefined, isJson: false } )
: { data: undefined, isJson: false }
const request = { const request = {
url: parseVariables(variables)( url: parseVariables(variables)(
webhook.url + (queryParams !== '' ? `?${queryParams}` : '') webhook.url + (queryParams !== '' ? `?${queryParams}` : '')
@@ -151,8 +153,7 @@ export const executeWebhook =
? body ? body
: undefined, : undefined,
form: contentType === 'x-www-form-urlencoded' && body ? body : undefined, form: contentType === 'x-www-form-urlencoded' && body ? body : undefined,
body: body: body && !isJson ? body : undefined,
body && !isJson && webhook.method !== HttpMethod.GET ? body : undefined,
} }
try { try {
const response = await got(request.url, omit(request, 'url')) const response = await got(request.url, omit(request, 'url'))

View File

@@ -12,16 +12,16 @@
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-commonjs": "22.0.2", "@rollup/plugin-commonjs": "22.0.2",
"@rollup/plugin-node-resolve": "^13.3.0", "@rollup/plugin-node-resolve": "^14.0.1",
"@rollup/plugin-typescript": "8.4.0", "@rollup/plugin-typescript": "8.5.0",
"rollup": "2.78.1", "rollup": "2.79.0",
"rollup-plugin-dts": "^4.2.2", "rollup-plugin-dts": "^4.2.2",
"rollup-plugin-peer-deps-external": "^2.2.4", "rollup-plugin-peer-deps-external": "^2.2.4",
"tslib": "^2.4.0", "tslib": "^2.4.0",
"typescript": "^4.8.2", "typescript": "^4.8.3",
"aws-sdk": "2.1204.0", "aws-sdk": "2.1213.0",
"models": "workspace:*", "models": "workspace:*",
"next": "12.2.5" "next": "12.3.0"
}, },
"peerDependencies": { "peerDependencies": {
"aws-sdk": "^2.1152.0", "aws-sdk": "^2.1152.0",