further fix for #192, also bug fix for starting with a ws connection and switching to webhooks later in the same call

This commit is contained in:
Dave Horton
2022-12-05 10:53:41 -05:00
parent c728417581
commit 46302703da
3 changed files with 4 additions and 4 deletions

View File

@@ -41,7 +41,7 @@ function retrieveCallSession(callSid, opts) {
router.post('/:callSid', async(req, res) => { router.post('/:callSid', async(req, res) => {
const logger = req.app.locals.logger; const logger = req.app.locals.logger;
const callSid = req.params.callSid; const callSid = req.params.callSid;
logger.debug({body: req.body}, 'got upateCall request'); logger.debug({body: req.body}, 'got updateCall request');
try { try {
const cs = retrieveCallSession(callSid, req.body); const cs = retrieveCallSession(callSid, req.body);
if (!cs) { if (!cs) {

View File

@@ -268,6 +268,7 @@ class TaskGather extends Task {
const {timeout} = opts; const {timeout} = opts;
this.timeout = timeout; this.timeout = timeout;
this._startTimer(); this._startTimer();
return true;
} }
_onDtmf(cs, ep, evt) { _onDtmf(cs, ep, evt) {
@@ -439,8 +440,7 @@ class TaskGather extends Task {
if (0 === this.timeout) return; if (0 === this.timeout) return;
this._clearTimer(); this._clearTimer();
this._timeoutTimer = setTimeout(() => { this._timeoutTimer = setTimeout(() => {
if (this.isContinuousAsr) this._startAsrTimer(); this._resolve(this.digitBuffer.length >= this.minDigits ? 'dtmf-num-digits' : 'timeout');
else this._resolve(this.digitBuffer.length >= this.minDigits ? 'dtmf-num-digits' : 'timeout');
}, this.timeout); }, this.timeout);
} }

View File

@@ -54,7 +54,7 @@ class WsRequestor extends BaseRequestor {
/* if we have an absolute url, and it is http then do a standard webhook */ /* if we have an absolute url, and it is http then do a standard webhook */
if (this._isAbsoluteUrl(url) && url.startsWith('http')) { if (this._isAbsoluteUrl(url) && url.startsWith('http')) {
this.logger.debug({hook}, 'WsRequestor: sending a webhook (HTTP)'); this.logger.debug({hook}, 'WsRequestor: sending a webhook (HTTP)');
const requestor = new HttpRequestor(this.logger, this.account_sid, hook, this.secret); const requestor = new HttpRequestor(this.logger, this.account_sid, {url: hook}, this.secret);
return requestor.request(type, hook, params, httpHeaders); return requestor.request(type, hook, params, httpHeaders);
} }