@babblevoice/babble-drachtio-callmanager 1.5.3 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/call.js CHANGED
@@ -1756,7 +1756,14 @@ class call {
1756
1756
  let sdp = sdpgen.create( req.msg.body )
1757
1757
  let media = sdp.getmedia()
1758
1758
 
1759
- if( ( "inactive" === media.direction || "0.0.0.0" === sdp.sdp.connection.ip ) && !this.state.held ) {
1759
+ let ip
1760
+ if( sdp && sdp && sdp.sdp.connection && sdp.sdp.connection.ip ) {
1761
+ ip = sdp.sdp.connection.ip
1762
+ }
1763
+
1764
+ /* this was tested against jssip - which I don't think is correct. It was sending us
1765
+ sendonly when placing the call on hold. It didn't change the connection IP (although it did set the rtcp connection ip to 0.0.0.0!). */
1766
+ if( ( "inactive" === media.direction || "sendonly" === media.direction || "0.0.0.0" === ip ) && !this.state.held ) {
1760
1767
  this._hold()
1761
1768
  res.send( 200, {
1762
1769
  "headers": {
@@ -1767,7 +1774,7 @@ class call {
1767
1774
  },
1768
1775
  "body": this.sdp.local.toString()
1769
1776
  } )
1770
- } else if( "inactive" !== media.direction && "0.0.0.0" !== sdp.sdp.connection.ip && this.state.held ) {
1777
+ } else if( "inactive" !== media.direction && "sendonly" !== media.direction && "0.0.0.0" !== ip && this.state.held ) {
1771
1778
  this._unhold()
1772
1779
  res.send( 200, {
1773
1780
  "headers": {
@@ -2344,6 +2351,9 @@ class call {
2344
2351
  @param { string } [ options.entity.realm ]
2345
2352
  @param { string } [ options.entity.uri ]
2346
2353
  @param { number } [ options.entity.max ] - if included no more than this number of calls for this entity (only if we look user up)
2354
+ @param { object } [ options.callerid ]
2355
+ @param { string } [ options.callerid.number ]
2356
+ @param { string } [ options.callerid.name ]
2347
2357
  @param { object } [ callbacks ]
2348
2358
  @param { earlycallback } [ callbacks.early ] - callback to provide a call object with early call (pre dialog)
2349
2359
  @param { confirmcallback } [ callbacks.confirm ] - called when a dialog is confirmed but before it is bridged with a parent - this provides an opportunity for another call to adopt this call
@@ -2454,6 +2464,17 @@ class call {
2454
2464
  }
2455
2465
  }
2456
2466
 
2467
+ /* oveide caller id */
2468
+ if( options.callerid ) {
2469
+ if( options.callerid.number ) {
2470
+ user = options.callerid.number
2471
+ }
2472
+
2473
+ if( options.callerid.name ) {
2474
+ name = options.callerid.name
2475
+ }
2476
+ }
2477
+
2457
2478
  let callerid = `"${name}" <sip:${user}@${realm}>`
2458
2479
 
2459
2480
  newcall.options.headers[ "Remote-Party-ID" ] = callerid
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babblevoice/babble-drachtio-callmanager",
3
- "version": "1.5.3",
3
+ "version": "1.6.1",
4
4
  "description": "Call processing to create a PBX",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1100,4 +1100,44 @@ describe( "call object", function() {
1100
1100
  c._onhangup( "wire" )
1101
1101
 
1102
1102
  } )
1103
+
1104
+ it( `overide caller id name`, async function() {
1105
+ new srf.srfscenario( {} )
1106
+
1107
+ let options = {
1108
+ "contact": "ourcontactstring",
1109
+ "callerid": {
1110
+ "name": "Hello"
1111
+ }
1112
+ }
1113
+
1114
+ let c = await call.newuac( options )
1115
+
1116
+ /* no default configured */
1117
+ expect( c.options.headers[ "Remote-Party-ID" ] ).to.equal( '"Hello" <sip:0000000000@localhost.localdomain>' )
1118
+
1119
+ c._onhangup( "wire" )
1120
+
1121
+ } )
1122
+
1123
+
1124
+ it( `overide caller id number`, async function() {
1125
+ new srf.srfscenario( {} )
1126
+
1127
+ let options = {
1128
+ "contact": "ourcontactstring",
1129
+ "callerid": {
1130
+ "number": "012345789"
1131
+ }
1132
+ }
1133
+
1134
+ let c = await call.newuac( options )
1135
+
1136
+
1137
+ /* no default configured */
1138
+ expect( c.options.headers[ "Remote-Party-ID" ] ).to.equal( '"" <sip:012345789@localhost.localdomain>' )
1139
+
1140
+ c._onhangup( "wire" )
1141
+
1142
+ } )
1103
1143
  } )