mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-07-23 20:42:16 +00:00
bugfix: queue event hook was getting set to register hook
This commit is contained in:
@@ -68,7 +68,7 @@ function transmogrifyResults(results) {
|
||||
|
||||
/* queue event hook */
|
||||
if (row.qh && Object.keys(row.qh).length && row.qh.url !== null) {
|
||||
Object.assign(obj, {queue_event_hook: row.rh});
|
||||
Object.assign(obj, {queue_event_hook: row.qh});
|
||||
delete obj.queue_event_hook.webhook_sid;
|
||||
}
|
||||
else obj.queue_event_hook = null;
|
||||
|
||||
@@ -253,6 +253,9 @@ async function validateAdd(req) {
|
||||
if (req.body.registration_hook && typeof req.body.registration_hook !== 'object') {
|
||||
throw new DbErrorBadRequest('\'registration_hook\' must be an object when adding an account');
|
||||
}
|
||||
if (req.body.queue_event_hook && typeof req.body.queue_event_hook !== 'object') {
|
||||
throw new DbErrorBadRequest('\'queue_event_hook\' must be an object when adding an account');
|
||||
}
|
||||
}
|
||||
async function validateUpdate(req, sid) {
|
||||
if (req.user.hasAccountAuth && req.user.account_sid !== sid) {
|
||||
@@ -292,11 +295,11 @@ router.post('/', async(req, res) => {
|
||||
|
||||
// create webhooks if provided
|
||||
const obj = {...req.body, webhook_secret: secret};
|
||||
for (const prop of ['registration_hook']) {
|
||||
if (obj[prop]) {
|
||||
for (const prop of ['registration_hook', 'queue_event_hook']) {
|
||||
if (obj[prop] && obj[prop].url && obj[prop].url.length > 0) {
|
||||
obj[`${prop}_sid`] = await Webhook.make(obj[prop]);
|
||||
delete obj[prop];
|
||||
}
|
||||
delete obj[prop];
|
||||
}
|
||||
|
||||
logger.debug(`Attempting to add account ${JSON.stringify(obj)}`);
|
||||
@@ -363,7 +366,7 @@ router.put('/:sid', async(req, res) => {
|
||||
const obj = Object.assign({}, req.body);
|
||||
for (const prop of ['registration_hook', 'queue_event_hook']) {
|
||||
if (prop in obj) {
|
||||
if (null === obj[prop]) {
|
||||
if (null === obj[prop] || !obj[prop].url || 0 === obj[prop].url.length) {
|
||||
obj[`${prop}_sid`] = null;
|
||||
}
|
||||
else if (typeof obj[prop] === 'object') {
|
||||
|
||||
Reference in New Issue
Block a user