webitel-sdk 23.9.4 → 23.9.5

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.
@@ -45440,22 +45440,26 @@ class Client extends EventEmitter {
45440
45440
  call.hangupAt = c.hangup_at || 0;
45441
45441
  // call.reportingAt = c.reporting_at || 0
45442
45442
  if (c.task) {
45443
- call.task = new Task(this, {
45444
- attempt_id: c.task.attempt_id,
45445
- channel: c.task.channel,
45446
- status: c.task.status,
45447
- timestamp: Date.now(),
45448
- }, c.task);
45449
- call.queue.reporting = 'true';
45450
- call.task.form = c.task.form || null;
45451
- if (c.leaving_at && c.task.processing_sec) {
45452
- call.task.startProcessingAt = c.leaving_at;
45453
- call.task.setProcessing(c.leaving_at, {
45454
- sec: c.task.processing_sec || 0,
45455
- timeout: c.task.processing_timeout_at || null,
45456
- renewal_sec: c.task.processing_renewal_sec || 0,
45457
- });
45443
+ let task = this.getTask(c.task.attempt_id);
45444
+ if (!task) {
45445
+ task = new Task(this, {
45446
+ attempt_id: c.task.attempt_id,
45447
+ channel: c.task.channel,
45448
+ status: c.task.status,
45449
+ timestamp: Date.now(),
45450
+ }, c.task);
45451
+ task.form = c.task.form || null;
45452
+ if (c.leaving_at && c.task.processing_sec) {
45453
+ task.startProcessingAt = c.leaving_at;
45454
+ task.setProcessing(c.leaving_at, {
45455
+ sec: c.task.processing_sec || 0,
45456
+ timeout: c.task.processing_timeout_at || null,
45457
+ renewal_sec: c.task.processing_renewal_sec || 0,
45458
+ });
45459
+ }
45458
45460
  }
45461
+ call.task = task;
45462
+ call.queue.reporting = 'true';
45459
45463
  }
45460
45464
  this.callStore.set(call.id, call);
45461
45465
  }
@@ -45473,22 +45477,26 @@ class Client extends EventEmitter {
45473
45477
  c.createdAt = conv.created_at;
45474
45478
  c.closedAt = conv.closed_at;
45475
45479
  if (conv.task) {
45476
- c.task = new Task(this, {
45477
- attempt_id: conv.task.attempt_id,
45478
- channel: conv.task.channel,
45479
- status: conv.task.status,
45480
- timestamp: Date.now(),
45481
- }, conv.task // todo add app_id
45482
- );
45483
- if (conv.leaving_at && conv.task.processing_sec) {
45484
- c.task.startProcessingAt = conv.leaving_at;
45485
- c.task.setProcessing(conv.leaving_at, {
45486
- sec: conv.task.processing_sec || 0,
45487
- timeout: conv.task.processing_timeout_at || null,
45488
- renewal_sec: conv.task.processing_renewal_sec || 0,
45489
- });
45480
+ let task = this.getTask(conv.task.attempt_id);
45481
+ if (!task) {
45482
+ task = new Task(this, {
45483
+ attempt_id: conv.task.attempt_id,
45484
+ channel: conv.task.channel,
45485
+ status: conv.task.status,
45486
+ timestamp: Date.now(),
45487
+ }, conv.task // todo add app_id
45488
+ );
45489
+ if (conv.leaving_at && conv.task.processing_sec) {
45490
+ task.startProcessingAt = conv.leaving_at;
45491
+ task.setProcessing(conv.leaving_at, {
45492
+ sec: conv.task.processing_sec || 0,
45493
+ timeout: conv.task.processing_timeout_at || null,
45494
+ renewal_sec: conv.task.processing_renewal_sec || 0,
45495
+ });
45496
+ }
45497
+ task.form = conv.task.form || null;
45490
45498
  }
45491
- c.task.form = conv.task.form || null;
45499
+ c.task = task;
45492
45500
  }
45493
45501
  if (conv.invite_id) {
45494
45502
  c.setInvite(conv.invite_id, conv.created_at);
@@ -45519,6 +45527,12 @@ class Client extends EventEmitter {
45519
45527
  this.eventHandler.on(WEBSOCKET_EVENT_AGENT_STATUS, handler);
45520
45528
  return res;
45521
45529
  }
45530
+ getTask(id) {
45531
+ if (!this.agent) {
45532
+ return undefined;
45533
+ }
45534
+ return this.agent.task.get(id);
45535
+ }
45522
45536
  subscribeTask(handler) {
45523
45537
  this.eventHandler.on(TASK_EVENT, handler);
45524
45538
  }