diff --git a/lib/session/call-session.js b/lib/session/call-session.js index 271d8dec..d48c451f 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -1781,6 +1781,15 @@ class CallSession extends Emitter { this.callInfo.updateCallStatus(callStatus, sipStatus, sipReason); if (typeof duration === 'number') this.callInfo.duration = duration; + this.executeStatusCallback(callStatus, sipStatus); + + // update calls db + //this.logger.debug(`updating redis with ${JSON.stringify(this.callInfo)}`); + this.updateCallStatus(Object.assign({}, this.callInfo.toJSON()), this.serviceUrl) + .catch((err) => this.logger.error(err, 'redis error')); + } + + async executeStatusCallback(callStatus, sipStatus) { const {span} = this.rootSpan.startChildSpan(`call-status:${this.callInfo.callStatus}`); span.setAttributes(this.callInfo.toJSON()); try { @@ -1792,11 +1801,6 @@ class CallSession extends Emitter { span.end(); this.logger.info(err, `CallSession:_notifyCallStatusChange error sending ${callStatus} ${sipStatus}`); } - - // update calls db - //this.logger.debug(`updating redis with ${JSON.stringify(this.callInfo)}`); - this.updateCallStatus(Object.assign({}, this.callInfo.toJSON()), this.serviceUrl) - .catch((err) => this.logger.error(err, 'redis error')); } async enableRecordAllCall() {