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

@@ -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;
}