fix(placetel): Parse request body inside of run method
This commit is contained in:
@@ -73,6 +73,7 @@
|
||||
"pg": "^8.7.1",
|
||||
"php-serialize": "^4.0.2",
|
||||
"pluralize": "^8.0.0",
|
||||
"raw-body": "^2.5.2",
|
||||
"showdown": "^2.1.0",
|
||||
"stripe": "^11.13.0",
|
||||
"winston": "^3.7.1",
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import Crypto from 'crypto';
|
||||
import { IJSONObject } from '@automatisch/types';
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
import getRawBody from 'raw-body';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'Hungup Call',
|
||||
@@ -68,6 +69,13 @@ export default defineTrigger({
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const stringBody = await getRawBody($.request, {
|
||||
length: $.request.headers['content-length'],
|
||||
encoding: true,
|
||||
});
|
||||
|
||||
const jsonRequestBody = JSON.parse(stringBody);
|
||||
|
||||
let types = ($.step.parameters.types as IJSONObject[]).map(
|
||||
(type) => type.type
|
||||
);
|
||||
@@ -76,9 +84,9 @@ export default defineTrigger({
|
||||
types = ['all'];
|
||||
}
|
||||
|
||||
if (types.includes($.request.body.type) || types.includes('all')) {
|
||||
if (types.includes(jsonRequestBody.type) || types.includes('all')) {
|
||||
const dataItem = {
|
||||
raw: $.request.body,
|
||||
raw: jsonRequestBody,
|
||||
meta: {
|
||||
internalId: Crypto.randomUUID(),
|
||||
},
|
||||
|
10
yarn.lock
10
yarn.lock
@@ -15204,6 +15204,16 @@ raw-body@^2.4.1:
|
||||
iconv-lite "0.4.24"
|
||||
unpipe "1.0.0"
|
||||
|
||||
raw-body@^2.5.2:
|
||||
version "2.5.2"
|
||||
resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.2.tgz#99febd83b90e08975087e8f1f9419a149366b68a"
|
||||
integrity sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==
|
||||
dependencies:
|
||||
bytes "3.1.2"
|
||||
http-errors "2.0.0"
|
||||
iconv-lite "0.4.24"
|
||||
unpipe "1.0.0"
|
||||
|
||||
rc@^1.2.8:
|
||||
version "1.2.8"
|
||||
resolved "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz"
|
||||
|
Reference in New Issue
Block a user