From 13549286db6fd70fff272f3500866754ad9943c1 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Mon, 2 May 2022 09:42:04 -0400 Subject: [PATCH] bugfix: createCall needs to work with wss url --- lib/http-routes/api/create-call.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/http-routes/api/create-call.js b/lib/http-routes/api/create-call.js index 67516921..2df72767 100644 --- a/lib/http-routes/api/create-call.js +++ b/lib/http-routes/api/create-call.js @@ -118,16 +118,17 @@ router.post('/', async(req, res) => { * attach our requestor and notifier objects * these will be used for all http requests we make during this call */ - if ('WS' === app.call_hook?.method) { + if ('WS' === app.call_hook?.method || /^wss?:/.test(app.call_hook.url)) { app.requestor = new WsRequestor(logger, account.account_sid, app.call_hook, account.webhook_secret) ; - app.notifier = app.requestor; + if (app.call_hook.url === app.call_status_hook.url || !app.call_status_hook?.url) app.notifier = app.requestor; } else { app.requestor = new HttpRequestor(logger, account.account_sid, app.call_hook, account.webhook_secret); - if (app.call_status_hook) app.notifier = new HttpRequestor(logger, account.account_sid, app.call_status_hook, - account.webhook_secret); - else app.notifier = {request: () => {}}; } + if (!app.notifier && app.call_status_hook) { + app.notifier = new HttpRequestor(logger, account.account_sid, app.call_status_hook, account.webhook_secret); + } + else if (!app.notifier) app.notifier = {request: () => {}}; /* now launch the outdial */ try {