add custom nye headers to completed hook (#1552)

This commit is contained in:
Sam Machin
2026-05-21 10:02:28 -04:00
committed by GitHub
parent c1a7f1146a
commit d84690dfb1
6 changed files with 60 additions and 16 deletions
+5 -4
View File
@@ -51,21 +51,22 @@ class RestCallSession extends CallSession {
/**
* This is invoked when the called party hangs up, in order to calculate the call duration.
*/
_callerHungup() {
this._hangup('caller');
_callerHungup(req) {
this._hangup('caller', req);
}
_jambonzHangup() {
this._hangup();
}
_hangup(terminatedBy = 'jambonz') {
_hangup(terminatedBy = 'jambonz', req) {
if (this.restDialTask) {
this.restDialTask.turnOffAmd();
}
this.callInfo.callTerminationBy = terminatedBy;
const duration = moment().diff(this.dlg.connectTime, 'seconds');
this.emit('callStatusChange', {callStatus: CallStatus.Completed, duration});
const headers = this._extractCustomHeaders(req);
this.emit('callStatusChange', {callStatus: CallStatus.Completed, duration, ...(headers && {headers})});
this.logger.info(`RestCallSession: called party hung up by ${terminatedBy}`);
this._callReleased();
}