mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
snakecase fix, include sip_status in dial action hook
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
"jsx": false,
|
||||
"modules": false
|
||||
},
|
||||
"ecmaVersion": 2017
|
||||
"ecmaVersion": 2018
|
||||
},
|
||||
"plugins": ["promise"],
|
||||
"rules": {
|
||||
|
||||
@@ -328,6 +328,7 @@ class TaskDial extends Task {
|
||||
if (this.results.dialCallStatus !== CallStatus.Completed) {
|
||||
Object.assign(this.results, {
|
||||
dialCallStatus: obj.callStatus,
|
||||
dialSipStatus: obj.sipStatus,
|
||||
dialCallSid: sd.callSid,
|
||||
});
|
||||
}
|
||||
@@ -436,6 +437,7 @@ class TaskDial extends Task {
|
||||
|
||||
Object.assign(this.results, {
|
||||
dialCallStatus: CallStatus.Completed,
|
||||
dialSipStatus: 200,
|
||||
dialCallSid: sd.callSid,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const bent = require('bent');
|
||||
const parseUrl = require('parse-url');
|
||||
const assert = require('assert');
|
||||
const snakeCaseKeys = require('snakecase-keys');
|
||||
const snakeCaseKeys = require('./snakecase-keys');
|
||||
const toBase64 = (str) => Buffer.from(str || '', 'utf8').toString('base64');
|
||||
|
||||
function basicAuth(username, password) {
|
||||
@@ -62,7 +62,7 @@ class Requestor {
|
||||
* @param {object} [params] - request parameters
|
||||
*/
|
||||
async request(hook, params) {
|
||||
const payload = params ? snakeCaseKeys(params, {exclude: ['customerData', 'sip']}) : null;
|
||||
const payload = params ? snakeCaseKeys(params, ['customerData', 'sip']) : null;
|
||||
const url = hook.url || hook;
|
||||
const method = hook.method || 'POST';
|
||||
const {username, password} = typeof hook === 'object' ? hook : {};
|
||||
|
||||
22
lib/utils/snakecase-keys.js
Normal file
22
lib/utils/snakecase-keys.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const snakeCase = require('to-snake-case');
|
||||
|
||||
const isObject = (value) => typeof value === 'object' && value !== null;
|
||||
|
||||
const snakeObject = (obj, excludes) => {
|
||||
const target = {};
|
||||
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (excludes.includes(key)) {
|
||||
target[key] = value;
|
||||
continue;
|
||||
}
|
||||
const newKey = snakeCase(key);
|
||||
const newValue = isObject(value) ? snakeObject(value, excludes) : value;
|
||||
target[newKey] = newValue;
|
||||
}
|
||||
return target;
|
||||
};
|
||||
|
||||
module.exports = (obj, excludes = []) => {
|
||||
return snakeObject(obj, excludes);
|
||||
};
|
||||
24
package-lock.json
generated
24
package-lock.json
generated
@@ -21,10 +21,11 @@
|
||||
"drachtio-srf": "^4.4.48",
|
||||
"express": "^4.17.1",
|
||||
"ip": "^1.1.5",
|
||||
"map-obj": "^4.2.1",
|
||||
"moment": "^2.29.1",
|
||||
"parse-url": "^5.0.2",
|
||||
"pino": "^6.11.1",
|
||||
"snakecase-keys": "^3.2.1",
|
||||
"to-snake-case": "^1.0.0",
|
||||
"uuid": "^8.3.2",
|
||||
"verify-aws-sns-signature": "^0.0.6",
|
||||
"xml2js": "^0.4.23"
|
||||
@@ -4269,18 +4270,6 @@
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/snakecase-keys": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/snakecase-keys/-/snakecase-keys-3.2.1.tgz",
|
||||
"integrity": "sha512-CjU5pyRfwOtaOITYv5C8DzpZ8XA/ieRsDpr93HI2r6e3YInC6moZpSQbmUtg8cTk58tq2x3jcG2gv+p1IZGmMA==",
|
||||
"dependencies": {
|
||||
"map-obj": "^4.1.0",
|
||||
"to-snake-case": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/sonic-boom": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-1.3.2.tgz",
|
||||
@@ -8691,15 +8680,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"snakecase-keys": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/snakecase-keys/-/snakecase-keys-3.2.1.tgz",
|
||||
"integrity": "sha512-CjU5pyRfwOtaOITYv5C8DzpZ8XA/ieRsDpr93HI2r6e3YInC6moZpSQbmUtg8cTk58tq2x3jcG2gv+p1IZGmMA==",
|
||||
"requires": {
|
||||
"map-obj": "^4.1.0",
|
||||
"to-snake-case": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"sonic-boom": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-1.3.2.tgz",
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
"moment": "^2.29.1",
|
||||
"parse-url": "^5.0.2",
|
||||
"pino": "^6.11.1",
|
||||
"snakecase-keys": "^3.2.1",
|
||||
"to-snake-case": "^1.0.0",
|
||||
"uuid": "^8.3.2",
|
||||
"verify-aws-sns-signature": "^0.0.6",
|
||||
"xml2js": "^0.4.23"
|
||||
|
||||
Reference in New Issue
Block a user