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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user