bugfix #14 - incorrect from when PAI differs from From header

This commit is contained in:
Dave Horton
2020-04-06 11:30:46 -04:00
parent 018ef8ddd3
commit f54513f166
3 changed files with 12 additions and 17 deletions

View File

@@ -81,7 +81,7 @@ router.post('/', async(req, res) => {
res.status(500).send('Call Failure');
ep.destroy();
}
/* ok our outbound NVITE is in flight */
/* ok our outbound INVITE is in flight */
const tasks = [restDial];
const callInfo = new CallInfo({

View File

@@ -1,4 +1,5 @@
const {CallDirection, CallStatus} = require('../utils/constants');
const parseUri = require('drachtio-srf').parseUri;
const uuidv4 = require('uuid/v4');
/**
@@ -7,16 +8,22 @@ const uuidv4 = require('uuid/v4');
*/
class CallInfo {
constructor(opts) {
let from ;
this.direction = opts.direction;
if (opts.req) {
const u = opts.req.getParsedHeader('from');
const uri = parseUri(u.uri);
from = uri.user;
this.callerName = u.name || '';
}
if (this.direction === CallDirection.Inbound) {
// inbound call
const {app, req} = opts;
this.callSid = req.locals.callSid,
this.accountSid = app.account_sid,
this.applicationSid = app.application_sid;
this.from = req.callingNumber;
this.from = from || req.callingNumber;
this.to = req.calledNumber;
this.callerName = this.from.name || req.callingNumber;
this.callId = req.get('Call-ID');
this.sipStatus = 100;
this.callStatus = CallStatus.Trying;
@@ -30,7 +37,7 @@ class CallInfo {
this.parentCallSid = parentCallInfo.callSid;
this.accountSid = parentCallInfo.accountSid;
this.applicationSid = parentCallInfo.applicationSid;
this.from = req.callingNumber;
this.from = from || req.callingNumber;
this.to = to;
this.callerId = this.from.name || req.callingNumber;
this.callId = req.get('Call-ID');
@@ -46,7 +53,7 @@ class CallInfo {
this.callStatus = CallStatus.Trying,
this.callId = req.get('Call-ID');
this.sipStatus = 100;
this.from = req.callingNumber;
this.from = from || req.callingNumber;
this.to = to;
if (tag) this._customerData = tag;
}

View File

@@ -242,18 +242,6 @@ class TaskDial extends Task {
const {getSBC} = srf.locals;
const sbcAddress = getSBC();
/*
if (CallDirection.Inbound === cs.direction) {
const contact = req.getParsedHeader('Contact');
const uri = parseUri(contact[0].uri);
this.logger.debug({contact}, 'outdialing with contact');
sbcAddress = `${uri.host}:${uri.port || 5060}`;
//sbcAddress = `${req.source_address}:${req.source_port}`;
}
else {
sbcAddress = getSBC();
}
*/
if (!sbcAddress) throw new Error('no SBC found for outbound call');
const opts = {
headers: req && req.has('X-CID') ? Object.assign(this.headers, {'X-CID': req.get('X-CID')}) : this.headers,