mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
bugfix #14 - incorrect from when PAI differs from From header
This commit is contained in:
@@ -81,7 +81,7 @@ router.post('/', async(req, res) => {
|
|||||||
res.status(500).send('Call Failure');
|
res.status(500).send('Call Failure');
|
||||||
ep.destroy();
|
ep.destroy();
|
||||||
}
|
}
|
||||||
/* ok our outbound NVITE is in flight */
|
/* ok our outbound INVITE is in flight */
|
||||||
|
|
||||||
const tasks = [restDial];
|
const tasks = [restDial];
|
||||||
const callInfo = new CallInfo({
|
const callInfo = new CallInfo({
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
const {CallDirection, CallStatus} = require('../utils/constants');
|
const {CallDirection, CallStatus} = require('../utils/constants');
|
||||||
|
const parseUri = require('drachtio-srf').parseUri;
|
||||||
const uuidv4 = require('uuid/v4');
|
const uuidv4 = require('uuid/v4');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -7,16 +8,22 @@ const uuidv4 = require('uuid/v4');
|
|||||||
*/
|
*/
|
||||||
class CallInfo {
|
class CallInfo {
|
||||||
constructor(opts) {
|
constructor(opts) {
|
||||||
|
let from ;
|
||||||
this.direction = opts.direction;
|
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) {
|
if (this.direction === CallDirection.Inbound) {
|
||||||
// inbound call
|
// inbound call
|
||||||
const {app, req} = opts;
|
const {app, req} = opts;
|
||||||
this.callSid = req.locals.callSid,
|
this.callSid = req.locals.callSid,
|
||||||
this.accountSid = app.account_sid,
|
this.accountSid = app.account_sid,
|
||||||
this.applicationSid = app.application_sid;
|
this.applicationSid = app.application_sid;
|
||||||
this.from = req.callingNumber;
|
this.from = from || req.callingNumber;
|
||||||
this.to = req.calledNumber;
|
this.to = req.calledNumber;
|
||||||
this.callerName = this.from.name || req.callingNumber;
|
|
||||||
this.callId = req.get('Call-ID');
|
this.callId = req.get('Call-ID');
|
||||||
this.sipStatus = 100;
|
this.sipStatus = 100;
|
||||||
this.callStatus = CallStatus.Trying;
|
this.callStatus = CallStatus.Trying;
|
||||||
@@ -30,7 +37,7 @@ class CallInfo {
|
|||||||
this.parentCallSid = parentCallInfo.callSid;
|
this.parentCallSid = parentCallInfo.callSid;
|
||||||
this.accountSid = parentCallInfo.accountSid;
|
this.accountSid = parentCallInfo.accountSid;
|
||||||
this.applicationSid = parentCallInfo.applicationSid;
|
this.applicationSid = parentCallInfo.applicationSid;
|
||||||
this.from = req.callingNumber;
|
this.from = from || req.callingNumber;
|
||||||
this.to = to;
|
this.to = to;
|
||||||
this.callerId = this.from.name || req.callingNumber;
|
this.callerId = this.from.name || req.callingNumber;
|
||||||
this.callId = req.get('Call-ID');
|
this.callId = req.get('Call-ID');
|
||||||
@@ -46,7 +53,7 @@ class CallInfo {
|
|||||||
this.callStatus = CallStatus.Trying,
|
this.callStatus = CallStatus.Trying,
|
||||||
this.callId = req.get('Call-ID');
|
this.callId = req.get('Call-ID');
|
||||||
this.sipStatus = 100;
|
this.sipStatus = 100;
|
||||||
this.from = req.callingNumber;
|
this.from = from || req.callingNumber;
|
||||||
this.to = to;
|
this.to = to;
|
||||||
if (tag) this._customerData = tag;
|
if (tag) this._customerData = tag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,18 +242,6 @@ class TaskDial extends Task {
|
|||||||
const {getSBC} = srf.locals;
|
const {getSBC} = srf.locals;
|
||||||
const sbcAddress = getSBC();
|
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');
|
if (!sbcAddress) throw new Error('no SBC found for outbound call');
|
||||||
const opts = {
|
const opts = {
|
||||||
headers: req && req.has('X-CID') ? Object.assign(this.headers, {'X-CID': req.get('X-CID')}) : this.headers,
|
headers: req && req.has('X-CID') ? Object.assign(this.headers, {'X-CID': req.get('X-CID')}) : this.headers,
|
||||||
|
|||||||
Reference in New Issue
Block a user