fix exception in dial verb when dtmf detected but detector not in place

This commit is contained in:
Dave Horton
2020-03-30 09:17:00 -04:00
parent 43c8890faf
commit a4286fefea

View File

@@ -206,11 +206,12 @@ class TaskDial extends Task {
_removeDtmfDetection(cs, ep) { _removeDtmfDetection(cs, ep) {
if (ep) { if (ep) {
delete ep.dtmfDetector; delete ep.dtmfDetector;
ep.removeListener('dtmf', this._onDtmf.bind(this, cs, ep)); ep.removeAllListeners('dtmf');
} }
} }
_onDtmf(cs, ep, evt) { _onDtmf(cs, ep, evt) {
if (ep.dtmfDetector) {
const match = ep.dtmfDetector.keyPress(evt.dtmf); const match = ep.dtmfDetector.keyPress(evt.dtmf);
const requestor = ep.dtmfDetector === this.parentDtmfCollector ? const requestor = ep.dtmfDetector === this.parentDtmfCollector ?
cs.requestor : cs.requestor :
@@ -221,6 +222,7 @@ class TaskDial extends Task {
.catch((err) => this.logger.info(err, 'Dial:_onDtmf - error')); .catch((err) => this.logger.info(err, 'Dial:_onDtmf - error'));
} }
} }
}
async _initializeInbound(cs) { async _initializeInbound(cs) {
const ep = await cs._evalEndpointPrecondition(this); const ep = await cs._evalEndpointPrecondition(this);