webitel-sdk 0.1.91 → 0.1.92

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.
@@ -22430,6 +22430,7 @@ class Task {
22430
22430
  this.offeringAt = 0;
22431
22431
  this.answeredAt = 0;
22432
22432
  this.bridgedAt = 0;
22433
+ this.reportedAt = 0;
22433
22434
  this.startProcessingAt = 0;
22434
22435
  this.stopAt = 0;
22435
22436
  this.closedAt = 0;
@@ -22488,7 +22489,7 @@ class Task {
22488
22489
  this.startProcessingAt = Date.now();
22489
22490
  }
22490
22491
  if (p.sec) {
22491
- p.timeout = Date.now() + p.sec * 1000; // bug
22492
+ p.timeout = this.startProcessingAt + p.sec * 1000; // bug
22492
22493
  }
22493
22494
  this._processing = p;
22494
22495
  }
@@ -22540,10 +22541,12 @@ class Task {
22540
22541
  });
22541
22542
  }
22542
22543
  async reporting(reporting) {
22543
- return this.client.request('cc_reporting', {
22544
+ const res = await this.client.request('cc_reporting', {
22544
22545
  attempt_id: this.id,
22545
22546
  ...reporting,
22546
22547
  });
22548
+ this.reportedAt = Date.now();
22549
+ return res;
22547
22550
  }
22548
22551
  async renew(sec) {
22549
22552
  return this.client.request('cc_renewal', {
@@ -23564,7 +23567,7 @@ class Client extends EventEmitter {
23564
23567
  call.answeredAt = c.answered_at || 0;
23565
23568
  call.bridgedAt = c.bridged_at || 0;
23566
23569
  call.hangupAt = c.hangup_at || 0;
23567
- call.reportingAt = c.reporting_at || 0;
23570
+ // call.reportingAt = c.reporting_at || 0
23568
23571
  if (c.task) {
23569
23572
  call.task = new Task(this, {
23570
23573
  attempt_id: c.task.attempt_id,
@@ -23574,6 +23577,14 @@ class Client extends EventEmitter {
23574
23577
  }, c.task // todo add app_id
23575
23578
  );
23576
23579
  call.queue.reporting = 'true';
23580
+ if (c.leaving_at && c.task.processing_sec) {
23581
+ call.task.startProcessingAt = c.leaving_at;
23582
+ call.task.setProcessing({
23583
+ sec: c.task.processing_sec || 0,
23584
+ timeout: Date.now() - c.leaving_at + (c.task.processing_sec || 0) * 1000,
23585
+ renewal_sec: c.task.processing_renewal_sec || 0,
23586
+ });
23587
+ }
23577
23588
  }
23578
23589
  this.callStore.set(call.id, call);
23579
23590
  }
@@ -23589,6 +23600,26 @@ class Client extends EventEmitter {
23589
23600
  const messages = conv.messages.reverse();
23590
23601
  const c = new Conversation(this, conv.id, conv.title, conv.members, messages, conv.variables);
23591
23602
  c.createdAt = conv.created_at;
23603
+ c.closedAt = conv.closed_at;
23604
+ if (conv.task) {
23605
+ c.task = new Task(this, {
23606
+ attempt_id: conv.task.attempt_id,
23607
+ channel: conv.task.channel,
23608
+ status: conv.task.status,
23609
+ timestamp: Date.now(),
23610
+ }, conv.task // todo add app_id
23611
+ );
23612
+ if (conv.leaving_at && conv.task.processing_sec) {
23613
+ c.task.startProcessingAt = conv.leaving_at;
23614
+ c.task.setProcessing({
23615
+ sec: conv.task.processing_sec || 0,
23616
+ timeout: Date.now() -
23617
+ conv.leaving_at +
23618
+ (conv.task.processing_sec || 0) * 1000,
23619
+ renewal_sec: conv.task.processing_renewal_sec || 0,
23620
+ });
23621
+ }
23622
+ }
23592
23623
  if (conv.invite_id) {
23593
23624
  c.setInvite(conv.invite_id, conv.created_at);
23594
23625
  }