bugfix: switching to http webhook during a ws session

This commit is contained in:
Dave Horton
2023-02-11 21:09:23 -05:00
parent e990b5dbf9
commit c7eacdd0f8
2 changed files with 2 additions and 2 deletions

View File

@@ -2,7 +2,6 @@ const {Client, Pool} = require('undici');
const parseUrl = require('parse-url');
const assert = require('assert');
const BaseRequestor = require('./base-requestor');
const WsRequestor = require('./ws-requestor');
const {HookMsgTypes} = require('./constants.json');
const snakeCaseKeys = require('./snakecase-keys');
const pools = new Map();
@@ -94,6 +93,7 @@ class HttpRequestor extends BaseRequestor {
/* if we have an absolute url, and it is ws then do a websocket connection */
if (this._isAbsoluteUrl(url) && url.startsWith('ws')) {
const WsRequestor = require('./ws-requestor');
this.logger.debug({hook}, 'HttpRequestor: switching to websocket connection');
const h = typeof hook === 'object' ? hook : {url: hook};
const requestor = new WsRequestor(this.logger, this.account_sid, h, this.secret);