mirror of
https://github.com/jambonz/sbc-outbound.git
synced 2025-12-19 04:27:45 +00:00
feat: record all call (#84)
* feat: record all call * feat: record all call * feat: record all call * feat: record all call * add record format in recording url * add record format to recording url * fix ext
This commit is contained in:
@@ -542,12 +542,18 @@ class CallSession extends Emitter {
|
||||
/* write cdr for connected call */
|
||||
if (this.req.locals.cdr) {
|
||||
const now = Date.now();
|
||||
const day = new Date();
|
||||
const recordAllCalls = this.req.locals.record_all_calls;
|
||||
let recording_url = `/Accounts/${this.account_sid}/RecentCalls/${this.req.locals.cdr.call_sid}/record`;
|
||||
recording_url += `/${day.getFullYear()}/${(day.getMonth() + 1).toString().padStart(2, '0')}`;
|
||||
recording_url += `/${day.getDate().toString().padStart(2, '0')}/${recordAllCalls}`;
|
||||
this.writeCdrs({...this.req.locals.cdr,
|
||||
terminated_at: now,
|
||||
termination_reason: dlg.type === 'uas' ? 'caller hungup' : 'called party hungup',
|
||||
sip_status: 200,
|
||||
answered: true,
|
||||
duration: Math.floor((now - callStart) / 1000)
|
||||
duration: Math.floor((now - callStart) / 1000),
|
||||
...(recordAllCalls && {recording_url})
|
||||
}).catch((err) => this.logger.error({err}, 'Error writing cdr for completed call'));
|
||||
}
|
||||
/* de-link the 2 Dialogs for GC */
|
||||
|
||||
@@ -19,6 +19,7 @@ module.exports = (srf, logger, redisClient) => {
|
||||
const callId = req.get('Call-ID');
|
||||
req.locals.account_sid = req.get('X-Account-Sid');
|
||||
req.locals.application_sid = req.get('X-Application-Sid');
|
||||
req.locals.record_all_calls = req.get('X-Record-All-Calls');
|
||||
const traceId = req.locals.trace_id = req.get('X-Trace-ID');
|
||||
req.locals.logger = logger.child({
|
||||
callId,
|
||||
|
||||
Reference in New Issue
Block a user