mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-01-25 02:08:24 +00:00
Fix/526 (#528)
* calidate webhook urls on update * don't remove webhooks if not updated * valid if object exists
This commit is contained in:
@@ -101,6 +101,20 @@ async function validateUpdate(req, sid) {
|
|||||||
if (req.body.call_status_hook && typeof req.body.call_hook !== 'object') {
|
if (req.body.call_status_hook && typeof req.body.call_hook !== 'object') {
|
||||||
throw new DbErrorBadRequest('\'call_status_hook\' must be an object when updating an application');
|
throw new DbErrorBadRequest('\'call_status_hook\' must be an object when updating an application');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let urlError;
|
||||||
|
if (req.body.call_hook) {
|
||||||
|
urlError = await isInvalidUrl(req.body.call_hook.url);
|
||||||
|
if (urlError) {
|
||||||
|
throw new DbErrorBadRequest(`call_hook ${urlError}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (req.body.call_status_hook) {
|
||||||
|
urlError = await isInvalidUrl(req.body.call_status_hook.url);
|
||||||
|
if (urlError) {
|
||||||
|
throw new DbErrorBadRequest(`call_status_hook ${urlError}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function validateDelete(req, sid) {
|
async function validateDelete(req, sid) {
|
||||||
@@ -290,9 +304,6 @@ router.put('/:sid', async(req, res) => {
|
|||||||
obj[`${prop}_sid`] = sid;
|
obj[`${prop}_sid`] = sid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
obj[`${prop}_sid`] = null;
|
|
||||||
}
|
|
||||||
delete obj[prop];
|
delete obj[prop];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user