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.
@@ -50306,7 +50306,7 @@
50306
50306
  };
50307
50307
  Client.prototype.subscribeCall = function (handler, data) {
50308
50308
  return tslib.__awaiter(this, void 0, void 0, function () {
50309
- var calls, _i, _a, c, e, call;
50309
+ var calls, _i, _a, c, e, call, task;
50310
50310
  return tslib.__generator(this, function (_b) {
50311
50311
  switch (_b.label) {
50312
50312
  case 0: return [4 /*yield*/, this.request("subscribe_call", data)];
@@ -50348,22 +50348,26 @@
50348
50348
  call.hangupAt = c.hangup_at || 0;
50349
50349
  // call.reportingAt = c.reporting_at || 0
50350
50350
  if (c.task) {
50351
- call.task = new Task(this, {
50352
- attempt_id: c.task.attempt_id,
50353
- channel: c.task.channel,
50354
- status: c.task.status,
50355
- timestamp: Date.now(),
50356
- }, c.task);
50357
- call.queue.reporting = 'true';
50358
- call.task.form = c.task.form || null;
50359
- if (c.leaving_at && c.task.processing_sec) {
50360
- call.task.startProcessingAt = c.leaving_at;
50361
- call.task.setProcessing(c.leaving_at, {
50362
- sec: c.task.processing_sec || 0,
50363
- timeout: c.task.processing_timeout_at || null,
50364
- renewal_sec: c.task.processing_renewal_sec || 0,
50365
- });
50351
+ task = this.getTask(c.task.attempt_id);
50352
+ if (!task) {
50353
+ task = new Task(this, {
50354
+ attempt_id: c.task.attempt_id,
50355
+ channel: c.task.channel,
50356
+ status: c.task.status,
50357
+ timestamp: Date.now(),
50358
+ }, c.task);
50359
+ task.form = c.task.form || null;
50360
+ if (c.leaving_at && c.task.processing_sec) {
50361
+ task.startProcessingAt = c.leaving_at;
50362
+ task.setProcessing(c.leaving_at, {
50363
+ sec: c.task.processing_sec || 0,
50364
+ timeout: c.task.processing_timeout_at || null,
50365
+ renewal_sec: c.task.processing_renewal_sec || 0,
50366
+ });
50367
+ }
50366
50368
  }
50369
+ call.task = task;
50370
+ call.queue.reporting = 'true';
50367
50371
  }
50368
50372
  this.callStore.set(call.id, call);
50369
50373
  }
@@ -50375,7 +50379,7 @@
50375
50379
  };
50376
50380
  Client.prototype.subscribeChat = function (handler, data) {
50377
50381
  return tslib.__awaiter(this, void 0, void 0, function () {
50378
- var res, _i, _a, conv, messages, c;
50382
+ var res, _i, _a, conv, messages, c, task;
50379
50383
  return tslib.__generator(this, function (_b) {
50380
50384
  switch (_b.label) {
50381
50385
  case 0: return [4 /*yield*/, this.request("subscribe_chat", data)];
@@ -50390,22 +50394,26 @@
50390
50394
  c.createdAt = conv.created_at;
50391
50395
  c.closedAt = conv.closed_at;
50392
50396
  if (conv.task) {
50393
- c.task = new Task(this, {
50394
- attempt_id: conv.task.attempt_id,
50395
- channel: conv.task.channel,
50396
- status: conv.task.status,
50397
- timestamp: Date.now(),
50398
- }, conv.task // todo add app_id
50399
- );
50400
- if (conv.leaving_at && conv.task.processing_sec) {
50401
- c.task.startProcessingAt = conv.leaving_at;
50402
- c.task.setProcessing(conv.leaving_at, {
50403
- sec: conv.task.processing_sec || 0,
50404
- timeout: conv.task.processing_timeout_at || null,
50405
- renewal_sec: conv.task.processing_renewal_sec || 0,
50406
- });
50397
+ task = this.getTask(conv.task.attempt_id);
50398
+ if (!task) {
50399
+ task = new Task(this, {
50400
+ attempt_id: conv.task.attempt_id,
50401
+ channel: conv.task.channel,
50402
+ status: conv.task.status,
50403
+ timestamp: Date.now(),
50404
+ }, conv.task // todo add app_id
50405
+ );
50406
+ if (conv.leaving_at && conv.task.processing_sec) {
50407
+ task.startProcessingAt = conv.leaving_at;
50408
+ task.setProcessing(conv.leaving_at, {
50409
+ sec: conv.task.processing_sec || 0,
50410
+ timeout: conv.task.processing_timeout_at || null,
50411
+ renewal_sec: conv.task.processing_renewal_sec || 0,
50412
+ });
50413
+ }
50414
+ task.form = conv.task.form || null;
50407
50415
  }
50408
- c.task.form = conv.task.form || null;
50416
+ c.task = task;
50409
50417
  }
50410
50418
  if (conv.invite_id) {
50411
50419
  c.setInvite(conv.invite_id, conv.created_at);
@@ -50457,6 +50465,12 @@
50457
50465
  });
50458
50466
  });
50459
50467
  };
50468
+ Client.prototype.getTask = function (id) {
50469
+ if (!this.agent) {
50470
+ return undefined;
50471
+ }
50472
+ return this.agent.task.get(id);
50473
+ };
50460
50474
  Client.prototype.subscribeTask = function (handler) {
50461
50475
  this.eventHandler.on(TASK_EVENT, handler);
50462
50476
  };