mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-07-24 04:52:03 +00:00
update call now uses POST, plus bugfix #6
This commit is contained in:
@@ -60,7 +60,7 @@ function validateUpdateCall(opts) {
|
||||
throw new DbErrorBadRequest('multiple options are not allowed in updateCall');
|
||||
}
|
||||
|
||||
if (opts.call_hook && !opts.call_hook.url) throw new DbErrorBadRequest('missing call_hook.url');
|
||||
if (typeof opts.call_hook === 'object' && !opts.call_hook.url) throw new DbErrorBadRequest('missing call_hook.url');
|
||||
if (opts.call_status && !['completed', 'no-answer'].includes(opts.call_status)) {
|
||||
throw new DbErrorBadRequest('invalid call_status');
|
||||
}
|
||||
@@ -131,7 +131,7 @@ async function validateCreateCall(logger, sid, req) {
|
||||
});
|
||||
}
|
||||
|
||||
if (!obj.call_hook || (obj.call_hook && !obj.call_hook.url)) {
|
||||
if (!obj.call_hook || (typeof obj.call_hook === 'object' && !obj.call_hook.url)) {
|
||||
throw new DbErrorBadRequest('either url or application_sid required');
|
||||
}
|
||||
}
|
||||
@@ -417,7 +417,7 @@ router.delete('/:sid/Calls/:callSid', async(req, res) => {
|
||||
/**
|
||||
* update a call
|
||||
*/
|
||||
router.post('/:sid/Calls/:callSid', async(req, res) => {
|
||||
const updateCall = async(req, res) => {
|
||||
const accountSid = req.params.sid;
|
||||
const callSid = req.params.callSid;
|
||||
const {logger, retrieveCall} = req.app.locals;
|
||||
@@ -443,6 +443,14 @@ router.post('/:sid/Calls/:callSid', async(req, res) => {
|
||||
} catch (err) {
|
||||
sysError(logger, res, err);
|
||||
}
|
||||
};
|
||||
|
||||
/** leaving for legacy purposes, this should have been (and now is) a PUT */
|
||||
router.post('/:sid/Calls/:callSid', async(req, res) => {
|
||||
await updateCall(req, res);
|
||||
});
|
||||
router.put('/:sid/Calls/:callSid', async(req, res) => {
|
||||
await updateCall(req, res);
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user