opensips-js 0.1.34 → 0.1.35

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.
@@ -24367,13 +24367,13 @@ class dS {
24367
24367
  * @param statusCode - SIP status code (100, 180, or 183)
24368
24368
  */
24369
24369
  handleSipResponseForRingback(t, n) {
24370
- var s, r, _, d, h;
24370
+ var s, r, _, d, h, m;
24371
24371
  let o = null;
24372
24372
  if (this.extendedCalls[t])
24373
24373
  o = t;
24374
24374
  else {
24375
- const m = Object.values(this.extendedCalls).find((T) => T.id === t || T._id === t || T.id && T.id.includes(t) || T._id && T._id.includes(t));
24376
- m && (o = m.id);
24375
+ const T = Object.values(this.extendedCalls).find((S) => S.id === t || S._id === t || S.id && S.id.includes(t) || S._id && S._id.includes(t));
24376
+ T && (o = T.id);
24377
24377
  }
24378
24378
  if (!o) {
24379
24379
  (s = this.context.logger) == null || s.warn(`[handleSipResponseForRingback] Could not find session for identifier ${t}, status ${n}`);
@@ -24385,15 +24385,20 @@ class dS {
24385
24385
  return;
24386
24386
  }
24387
24387
  if (a.direction === "outgoing") {
24388
+ if (a._is_confirmed) {
24389
+ (_ = this.context.logger) == null || _.log(`[handleSipResponseForRingback] Call ${o} is already confirmed, skipping ringback tone`);
24390
+ return;
24391
+ }
24388
24392
  if (n === ho.TRYING || n === ho.RINGING) {
24389
24393
  if (this.ringbackTimers[o])
24390
24394
  return;
24391
24395
  this.ringbackSessionProgressReceived[o] = !1, this.ringbackTimers[o] = setTimeout(() => {
24392
- var m;
24393
- this.ringbackSessionProgressReceived[o] || (this.startLocalRingbackTone(o), (m = this.context.logger) == null || m.log(`[handleSipResponseForRingback] Started local ringback tone for call ${o} after 2 seconds without 183`)), delete this.ringbackTimers[o];
24394
- }, 2e3), (_ = this.context.logger) == null || _.log(`[handleSipResponseForRingback] Started 2-second timer for call ${o} after receiving ${n}`);
24396
+ var S, E;
24397
+ const T = this.extendedCalls[o];
24398
+ T && !T._is_confirmed && !this.ringbackSessionProgressReceived[o] ? (this.startLocalRingbackTone(o), (S = this.context.logger) == null || S.log(`[handleSipResponseForRingback] Started local ringback tone for call ${o} after 2 seconds without 183`)) : T && T._is_confirmed && ((E = this.context.logger) == null || E.log(`[handleSipResponseForRingback] Call ${o} was confirmed during 2-second wait, skipping ringback tone`)), delete this.ringbackTimers[o];
24399
+ }, 2e3), (d = this.context.logger) == null || d.log(`[handleSipResponseForRingback] Started 2-second timer for call ${o} after receiving ${n}`);
24395
24400
  }
24396
- n === ho.SESSION_PROGRESS && (this.ringbackSessionProgressReceived[o] = !0, this.ringbackTimers[o] && (clearTimeout(this.ringbackTimers[o]), delete this.ringbackTimers[o], (d = this.context.logger) == null || d.log(`[handleSipResponseForRingback] Cancelled ringback timer for call ${o} - 183 received`)), this.stopLocalRingbackTone(o), (h = this.context.logger) == null || h.log(`[handleSipResponseForRingback] Stopped local ringback tone for call ${o} - 183 received with SDP`));
24401
+ n === ho.SESSION_PROGRESS && (this.ringbackSessionProgressReceived[o] = !0, this.ringbackTimers[o] && (clearTimeout(this.ringbackTimers[o]), delete this.ringbackTimers[o], (h = this.context.logger) == null || h.log(`[handleSipResponseForRingback] Cancelled ringback timer for call ${o} - 183 received`)), this.stopLocalRingbackTone(o), (m = this.context.logger) == null || m.log(`[handleSipResponseForRingback] Stopped local ringback tone for call ${o} - 183 received with SDP`));
24397
24402
  }
24398
24403
  }
24399
24404
  /**