bugfix: createCall needs to work with wss url

This commit is contained in:
Dave Horton
2022-05-02 09:42:04 -04:00
parent 72aaf80335
commit 13549286db

View File

@@ -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 {