webitel-sdk 0.1.89 → 0.1.93

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.
Files changed (54) hide show
  1. package/bundles/index.esm.js +212 -44
  2. package/bundles/index.esm.js.map +1 -1
  3. package/bundles/index.esm.min.js +1 -1
  4. package/bundles/index.esm.min.js.map +1 -1
  5. package/bundles/index.umd.js +239 -45
  6. package/bundles/index.umd.js.map +1 -1
  7. package/bundles/index.umd.min.js +1 -1
  8. package/bundles/index.umd.min.js.map +1 -1
  9. package/esm2015/api/engine-patch-queue-bucket-request.js +13 -0
  10. package/esm2015/api/engine-patch-queue-bucket-request.js.map +1 -0
  11. package/esm2015/api/index.js.map +1 -1
  12. package/esm2015/api/queue-bucket-service-api.js +125 -27
  13. package/esm2015/api/queue-bucket-service-api.js.map +1 -1
  14. package/esm2015/sip/webrtc/index.js +1 -1
  15. package/esm2015/sip/webrtc/index.js.map +1 -1
  16. package/esm2015/socket/client.js +54 -5
  17. package/esm2015/socket/client.js.map +1 -1
  18. package/esm2015/socket/conversation.js +26 -9
  19. package/esm2015/socket/conversation.js.map +1 -1
  20. package/esm2015/socket/task.js +6 -2
  21. package/esm2015/socket/task.js.map +1 -1
  22. package/esm5/api/engine-patch-queue-bucket-request.js +13 -0
  23. package/esm5/api/engine-patch-queue-bucket-request.js.map +1 -0
  24. package/esm5/api/index.js.map +1 -1
  25. package/esm5/api/queue-bucket-service-api.js +138 -27
  26. package/esm5/api/queue-bucket-service-api.js.map +1 -1
  27. package/esm5/sip/webrtc/index.js +1 -1
  28. package/esm5/sip/webrtc/index.js.map +1 -1
  29. package/esm5/socket/client.js +58 -6
  30. package/esm5/socket/client.js.map +1 -1
  31. package/esm5/socket/conversation.js +31 -9
  32. package/esm5/socket/conversation.js.map +1 -1
  33. package/esm5/socket/task.js +11 -2
  34. package/esm5/socket/task.js.map +1 -1
  35. package/package.json +1 -1
  36. package/types/api/engine-create-queue-bucket-request.d.ts +8 -2
  37. package/types/api/engine-create-queue-bucket-request.d.ts.map +1 -1
  38. package/types/api/engine-patch-queue-bucket-request.d.ts +62 -0
  39. package/types/api/engine-patch-queue-bucket-request.d.ts.map +1 -0
  40. package/types/api/engine-queue-bucket.d.ts +12 -0
  41. package/types/api/engine-queue-bucket.d.ts.map +1 -1
  42. package/types/api/engine-update-queue-bucket-request.d.ts +8 -2
  43. package/types/api/engine-update-queue-bucket-request.d.ts.map +1 -1
  44. package/types/api/index.d.ts +1 -0
  45. package/types/api/index.d.ts.map +1 -1
  46. package/types/api/queue-bucket-service-api.d.ts +46 -16
  47. package/types/api/queue-bucket-service-api.d.ts.map +1 -1
  48. package/types/socket/call.d.ts +2 -2
  49. package/types/socket/call.d.ts.map +1 -1
  50. package/types/socket/client.d.ts.map +1 -1
  51. package/types/socket/conversation.d.ts +15 -5
  52. package/types/socket/conversation.d.ts.map +1 -1
  53. package/types/socket/task.d.ts +3 -0
  54. package/types/socket/task.d.ts.map +1 -1
@@ -15169,11 +15169,10 @@ const QueueBucketServiceApiAxiosParamCreator = function (configuration) {
15169
15169
  * @summary DeleteQueueRouting
15170
15170
  * @param {string} queueId
15171
15171
  * @param {string} id
15172
- * @param {string} [domainId]
15173
15172
  * @param {*} [options] Override http request option.
15174
15173
  * @throws {RequiredError}
15175
15174
  */
15176
- deleteQueueBucket: async (queueId, id, domainId, options = {}) => {
15175
+ deleteQueueBucket: async (queueId, id, options = {}) => {
15177
15176
  // verify required parameter 'queueId' is not null or undefined
15178
15177
  if (queueId === null || queueId === undefined) {
15179
15178
  throw new RequiredError('queueId', 'Required parameter queueId was null or undefined when calling deleteQueueBucket.');
@@ -15204,9 +15203,68 @@ const QueueBucketServiceApiAxiosParamCreator = function (configuration) {
15204
15203
  : await configuration.apiKey;
15205
15204
  localVarHeaderParameter['X-Webitel-Access'] = localVarApiKeyValue;
15206
15205
  }
15207
- if (domainId !== undefined) {
15208
- localVarQueryParameter['domain_id'] = domainId;
15206
+ localVarUrlObj.query = {
15207
+ ...localVarUrlObj.query,
15208
+ ...localVarQueryParameter,
15209
+ ...options.query,
15210
+ };
15211
+ // fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
15212
+ delete localVarUrlObj.search;
15213
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
15214
+ localVarRequestOptions.headers = {
15215
+ ...localVarHeaderParameter,
15216
+ ...headersFromBaseOptions,
15217
+ ...options.headers,
15218
+ };
15219
+ return {
15220
+ url: format(localVarUrlObj),
15221
+ options: localVarRequestOptions,
15222
+ };
15223
+ },
15224
+ /**
15225
+ *
15226
+ * @param {string} queueId
15227
+ * @param {string} id
15228
+ * @param {EnginePatchQueueBucketRequest} body
15229
+ * @param {*} [options] Override http request option.
15230
+ * @throws {RequiredError}
15231
+ */
15232
+ patchQueueBucket: async (queueId, id, body, options = {}) => {
15233
+ // verify required parameter 'queueId' is not null or undefined
15234
+ if (queueId === null || queueId === undefined) {
15235
+ throw new RequiredError('queueId', 'Required parameter queueId was null or undefined when calling patchQueueBucket.');
15236
+ }
15237
+ // verify required parameter 'id' is not null or undefined
15238
+ if (id === null || id === undefined) {
15239
+ throw new RequiredError('id', 'Required parameter id was null or undefined when calling patchQueueBucket.');
15209
15240
  }
15241
+ // verify required parameter 'body' is not null or undefined
15242
+ if (body === null || body === undefined) {
15243
+ throw new RequiredError('body', 'Required parameter body was null or undefined when calling patchQueueBucket.');
15244
+ }
15245
+ const localVarPath = `/call_center/queues/{queue_id}/buckets/{id}`
15246
+ .replace(`{${'queue_id'}}`, encodeURIComponent(String(queueId)))
15247
+ .replace(`{${'id'}}`, encodeURIComponent(String(id)));
15248
+ const localVarUrlObj = parse(localVarPath, true);
15249
+ let baseOptions;
15250
+ if (configuration) {
15251
+ baseOptions = configuration.baseOptions;
15252
+ }
15253
+ const localVarRequestOptions = {
15254
+ method: 'PATCH',
15255
+ ...baseOptions,
15256
+ ...options,
15257
+ };
15258
+ const localVarHeaderParameter = {};
15259
+ const localVarQueryParameter = {};
15260
+ // authentication AccessToken required
15261
+ if (configuration && configuration.apiKey) {
15262
+ const localVarApiKeyValue = typeof configuration.apiKey === 'function'
15263
+ ? await configuration.apiKey('X-Webitel-Access')
15264
+ : await configuration.apiKey;
15265
+ localVarHeaderParameter['X-Webitel-Access'] = localVarApiKeyValue;
15266
+ }
15267
+ localVarHeaderParameter['Content-Type'] = 'application/json';
15210
15268
  localVarUrlObj.query = {
15211
15269
  ...localVarUrlObj.query,
15212
15270
  ...localVarQueryParameter,
@@ -15220,6 +15278,11 @@ const QueueBucketServiceApiAxiosParamCreator = function (configuration) {
15220
15278
  ...headersFromBaseOptions,
15221
15279
  ...options.headers,
15222
15280
  };
15281
+ const needsSerialization = typeof body !== 'string' ||
15282
+ localVarRequestOptions.headers['Content-Type'] === 'application/json';
15283
+ localVarRequestOptions.data = needsSerialization
15284
+ ? JSON.stringify(body !== undefined ? body : {})
15285
+ : body || '';
15223
15286
  return {
15224
15287
  url: format(localVarUrlObj),
15225
15288
  options: localVarRequestOptions,
@@ -15230,11 +15293,10 @@ const QueueBucketServiceApiAxiosParamCreator = function (configuration) {
15230
15293
  * @summary ReadQueueRouting
15231
15294
  * @param {string} queueId
15232
15295
  * @param {string} id
15233
- * @param {string} [domainId]
15234
15296
  * @param {*} [options] Override http request option.
15235
15297
  * @throws {RequiredError}
15236
15298
  */
15237
- readQueueBucket: async (queueId, id, domainId, options = {}) => {
15299
+ readQueueBucket: async (queueId, id, options = {}) => {
15238
15300
  // verify required parameter 'queueId' is not null or undefined
15239
15301
  if (queueId === null || queueId === undefined) {
15240
15302
  throw new RequiredError('queueId', 'Required parameter queueId was null or undefined when calling readQueueBucket.');
@@ -15265,9 +15327,6 @@ const QueueBucketServiceApiAxiosParamCreator = function (configuration) {
15265
15327
  : await configuration.apiKey;
15266
15328
  localVarHeaderParameter['X-Webitel-Access'] = localVarApiKeyValue;
15267
15329
  }
15268
- if (domainId !== undefined) {
15269
- localVarQueryParameter['domain_id'] = domainId;
15270
- }
15271
15330
  localVarUrlObj.query = {
15272
15331
  ...localVarUrlObj.query,
15273
15332
  ...localVarQueryParameter,
@@ -15459,12 +15518,29 @@ const QueueBucketServiceApiFp = function (configuration) {
15459
15518
  * @summary DeleteQueueRouting
15460
15519
  * @param {string} queueId
15461
15520
  * @param {string} id
15462
- * @param {string} [domainId]
15463
15521
  * @param {*} [options] Override http request option.
15464
15522
  * @throws {RequiredError}
15465
15523
  */
15466
- async deleteQueueBucket(queueId, id, domainId, options) {
15467
- const localVarAxiosArgs = await QueueBucketServiceApiAxiosParamCreator(configuration).deleteQueueBucket(queueId, id, domainId, options);
15524
+ async deleteQueueBucket(queueId, id, options) {
15525
+ const localVarAxiosArgs = await QueueBucketServiceApiAxiosParamCreator(configuration).deleteQueueBucket(queueId, id, options);
15526
+ return (axios = globalAxios, basePath = BASE_PATH) => {
15527
+ const axiosRequestArgs = {
15528
+ ...localVarAxiosArgs.options,
15529
+ url: basePath + localVarAxiosArgs.url,
15530
+ };
15531
+ return axios.request(axiosRequestArgs);
15532
+ };
15533
+ },
15534
+ /**
15535
+ *
15536
+ * @param {string} queueId
15537
+ * @param {string} id
15538
+ * @param {EnginePatchQueueBucketRequest} body
15539
+ * @param {*} [options] Override http request option.
15540
+ * @throws {RequiredError}
15541
+ */
15542
+ async patchQueueBucket(queueId, id, body, options) {
15543
+ const localVarAxiosArgs = await QueueBucketServiceApiAxiosParamCreator(configuration).patchQueueBucket(queueId, id, body, options);
15468
15544
  return (axios = globalAxios, basePath = BASE_PATH) => {
15469
15545
  const axiosRequestArgs = {
15470
15546
  ...localVarAxiosArgs.options,
@@ -15478,12 +15554,11 @@ const QueueBucketServiceApiFp = function (configuration) {
15478
15554
  * @summary ReadQueueRouting
15479
15555
  * @param {string} queueId
15480
15556
  * @param {string} id
15481
- * @param {string} [domainId]
15482
15557
  * @param {*} [options] Override http request option.
15483
15558
  * @throws {RequiredError}
15484
15559
  */
15485
- async readQueueBucket(queueId, id, domainId, options) {
15486
- const localVarAxiosArgs = await QueueBucketServiceApiAxiosParamCreator(configuration).readQueueBucket(queueId, id, domainId, options);
15560
+ async readQueueBucket(queueId, id, options) {
15561
+ const localVarAxiosArgs = await QueueBucketServiceApiAxiosParamCreator(configuration).readQueueBucket(queueId, id, options);
15487
15562
  return (axios = globalAxios, basePath = BASE_PATH) => {
15488
15563
  const axiosRequestArgs = {
15489
15564
  ...localVarAxiosArgs.options,
@@ -15560,13 +15635,25 @@ const QueueBucketServiceApiFactory = function (configuration, basePath, axios) {
15560
15635
  * @summary DeleteQueueRouting
15561
15636
  * @param {string} queueId
15562
15637
  * @param {string} id
15563
- * @param {string} [domainId]
15564
15638
  * @param {*} [options] Override http request option.
15565
15639
  * @throws {RequiredError}
15566
15640
  */
15567
- deleteQueueBucket(queueId, id, domainId, options) {
15641
+ deleteQueueBucket(queueId, id, options) {
15568
15642
  return QueueBucketServiceApiFp(configuration)
15569
- .deleteQueueBucket(queueId, id, domainId, options)
15643
+ .deleteQueueBucket(queueId, id, options)
15644
+ .then((request) => request(axios, basePath));
15645
+ },
15646
+ /**
15647
+ *
15648
+ * @param {string} queueId
15649
+ * @param {string} id
15650
+ * @param {EnginePatchQueueBucketRequest} body
15651
+ * @param {*} [options] Override http request option.
15652
+ * @throws {RequiredError}
15653
+ */
15654
+ patchQueueBucket(queueId, id, body, options) {
15655
+ return QueueBucketServiceApiFp(configuration)
15656
+ .patchQueueBucket(queueId, id, body, options)
15570
15657
  .then((request) => request(axios, basePath));
15571
15658
  },
15572
15659
  /**
@@ -15574,13 +15661,12 @@ const QueueBucketServiceApiFactory = function (configuration, basePath, axios) {
15574
15661
  * @summary ReadQueueRouting
15575
15662
  * @param {string} queueId
15576
15663
  * @param {string} id
15577
- * @param {string} [domainId]
15578
15664
  * @param {*} [options] Override http request option.
15579
15665
  * @throws {RequiredError}
15580
15666
  */
15581
- readQueueBucket(queueId, id, domainId, options) {
15667
+ readQueueBucket(queueId, id, options) {
15582
15668
  return QueueBucketServiceApiFp(configuration)
15583
- .readQueueBucket(queueId, id, domainId, options)
15669
+ .readQueueBucket(queueId, id, options)
15584
15670
  .then((request) => request(axios, basePath));
15585
15671
  },
15586
15672
  /**
@@ -15643,14 +15729,27 @@ class QueueBucketServiceApi extends BaseAPI {
15643
15729
  * @summary DeleteQueueRouting
15644
15730
  * @param {string} queueId
15645
15731
  * @param {string} id
15646
- * @param {string} [domainId]
15647
15732
  * @param {*} [options] Override http request option.
15648
15733
  * @throws {RequiredError}
15649
15734
  * @memberof QueueBucketServiceApi
15650
15735
  */
15651
- deleteQueueBucket(queueId, id, domainId, options) {
15736
+ deleteQueueBucket(queueId, id, options) {
15737
+ return QueueBucketServiceApiFp(this.configuration)
15738
+ .deleteQueueBucket(queueId, id, options)
15739
+ .then((request) => request(this.axios, this.basePath));
15740
+ }
15741
+ /**
15742
+ *
15743
+ * @param {string} queueId
15744
+ * @param {string} id
15745
+ * @param {EnginePatchQueueBucketRequest} body
15746
+ * @param {*} [options] Override http request option.
15747
+ * @throws {RequiredError}
15748
+ * @memberof QueueBucketServiceApi
15749
+ */
15750
+ patchQueueBucket(queueId, id, body, options) {
15652
15751
  return QueueBucketServiceApiFp(this.configuration)
15653
- .deleteQueueBucket(queueId, id, domainId, options)
15752
+ .patchQueueBucket(queueId, id, body, options)
15654
15753
  .then((request) => request(this.axios, this.basePath));
15655
15754
  }
15656
15755
  /**
@@ -15658,14 +15757,13 @@ class QueueBucketServiceApi extends BaseAPI {
15658
15757
  * @summary ReadQueueRouting
15659
15758
  * @param {string} queueId
15660
15759
  * @param {string} id
15661
- * @param {string} [domainId]
15662
15760
  * @param {*} [options] Override http request option.
15663
15761
  * @throws {RequiredError}
15664
15762
  * @memberof QueueBucketServiceApi
15665
15763
  */
15666
- readQueueBucket(queueId, id, domainId, options) {
15764
+ readQueueBucket(queueId, id, options) {
15667
15765
  return QueueBucketServiceApiFp(this.configuration)
15668
- .readQueueBucket(queueId, id, domainId, options)
15766
+ .readQueueBucket(queueId, id, options)
15669
15767
  .then((request) => request(this.axios, this.basePath));
15670
15768
  }
15671
15769
  /**
@@ -22165,7 +22263,7 @@ class SipPhone extends EventEmitter {
22165
22263
  }
22166
22264
  async unregister() {
22167
22265
  if (this.ua) {
22168
- this.ua.ua.terminateSessions();
22266
+ this.ua.terminateSessions();
22169
22267
  this.ua.removeAllListeners();
22170
22268
  await this.ua.stop();
22171
22269
  delete this.ua;
@@ -22332,6 +22430,7 @@ class Task {
22332
22430
  this.offeringAt = 0;
22333
22431
  this.answeredAt = 0;
22334
22432
  this.bridgedAt = 0;
22433
+ this.reportedAt = 0;
22335
22434
  this.startProcessingAt = 0;
22336
22435
  this.stopAt = 0;
22337
22436
  this.closedAt = 0;
@@ -22386,11 +22485,12 @@ class Task {
22386
22485
  this.lastStatusChange = Date.now();
22387
22486
  }
22388
22487
  setProcessing(p) {
22488
+ this.state = 'processing'; // todo
22389
22489
  if (!this.startProcessingAt) {
22390
22490
  this.startProcessingAt = Date.now();
22391
22491
  }
22392
22492
  if (p.sec) {
22393
- p.timeout = Date.now() + p.sec * 1000; // bug
22493
+ p.timeout = this.startProcessingAt + p.sec * 1000; // bug
22394
22494
  }
22395
22495
  this._processing = p;
22396
22496
  }
@@ -22442,10 +22542,12 @@ class Task {
22442
22542
  });
22443
22543
  }
22444
22544
  async reporting(reporting) {
22445
- return this.client.request('cc_reporting', {
22545
+ const res = await this.client.request('cc_reporting', {
22446
22546
  attempt_id: this.id,
22447
22547
  ...reporting,
22448
22548
  });
22549
+ this.reportedAt = Date.now();
22550
+ return res;
22449
22551
  }
22450
22552
  async renew(sec) {
22451
22553
  return this.client.request('cc_renewal', {
@@ -23149,7 +23251,13 @@ class Conversation {
23149
23251
  this.members = (members || []).map((i) => wrapChannelMember(i));
23150
23252
  this._messages = messages || [];
23151
23253
  this.state = ConversationState.Invite;
23152
- this.variables = variables;
23254
+ this.variables = {};
23255
+ this._hasReporting = !!(variables && variables.cc_reporting === 'true');
23256
+ for (const k in variables) {
23257
+ if (!k.startsWith('cc_') && variables.hasOwnProperty(k)) {
23258
+ this.variables[k] = variables[k];
23259
+ }
23260
+ }
23153
23261
  if (variables &&
23154
23262
  variables.hasOwnProperty('cc_attempt_id') &&
23155
23263
  this.client.agent) {
@@ -23172,7 +23280,7 @@ class Conversation {
23172
23280
  this.closedAt = timestamp;
23173
23281
  }
23174
23282
  get id() {
23175
- return this.conversationId;
23283
+ return this.channelId || this.inviteId || this.conversationId;
23176
23284
  }
23177
23285
  get messages() {
23178
23286
  return this.getMessages();
@@ -23186,6 +23294,7 @@ class Conversation {
23186
23294
  channelId: i.channel_id,
23187
23295
  createdAt: i.created_at,
23188
23296
  updatedAt: i.updated_at,
23297
+ contact: null,
23189
23298
  };
23190
23299
  if (i.hasOwnProperty('file')) {
23191
23300
  i.file.url = this.client.fileUrlDownload(i.file.id);
@@ -23194,6 +23303,9 @@ class Conversation {
23194
23303
  if (i.hasOwnProperty('text')) {
23195
23304
  msg.text = i.text;
23196
23305
  }
23306
+ if (i.hasOwnProperty('contact')) {
23307
+ msg.contact = i.contact;
23308
+ }
23197
23309
  return msg;
23198
23310
  });
23199
23311
  }
@@ -23219,7 +23331,14 @@ class Conversation {
23219
23331
  return this.answeredAt > 0 && this.hasReporting;
23220
23332
  }
23221
23333
  get hasReporting() {
23222
- return this.variables && this.variables.cc_reporting === 'true';
23334
+ return this._hasReporting;
23335
+ }
23336
+ get membersId() {
23337
+ const res = [this.id];
23338
+ for (const m of this.members) {
23339
+ res.push(m.id);
23340
+ }
23341
+ return res;
23223
23342
  }
23224
23343
  /*
23225
23344
  Actions
@@ -23243,7 +23362,7 @@ class Conversation {
23243
23362
  throw new Error('This conversation not active');
23244
23363
  return this.client.request(`close_chat`, {
23245
23364
  channel_id: this.channelId,
23246
- conversation_id: this.id,
23365
+ conversation_id: this.conversationId,
23247
23366
  cause,
23248
23367
  });
23249
23368
  }
@@ -23252,7 +23371,7 @@ class Conversation {
23252
23371
  throw new Error('This conversation not active');
23253
23372
  return this.client.request(`leave_chat`, {
23254
23373
  channel_id: this.channelId,
23255
- conversation_id: this.id,
23374
+ conversation_id: this.conversationId,
23256
23375
  cause,
23257
23376
  });
23258
23377
  }
@@ -23272,12 +23391,12 @@ class Conversation {
23272
23391
  }
23273
23392
  }
23274
23393
  async sendFile(file, cb) {
23275
- const storedFiles = await this.client.storeFile(this.id, [file], cb);
23394
+ const storedFiles = await this.client.storeFile(this.conversationId, [file], cb);
23276
23395
  const f = storedFiles[0];
23277
23396
  // todo bug if chat response error
23278
23397
  return this.client.request(`send_file_chat`, {
23279
23398
  channel_id: this.channelId,
23280
- conversation_id: this.id,
23399
+ conversation_id: this.conversationId,
23281
23400
  id: f.id,
23282
23401
  name: file.name,
23283
23402
  mime: f.mime,
@@ -23299,7 +23418,7 @@ class Conversation {
23299
23418
  async addToChat(userId, title) {
23300
23419
  return this.client.request(`add_to_chat`, {
23301
23420
  channel_id: this.channelId,
23302
- conversation_id: this.id,
23421
+ conversation_id: this.conversationId,
23303
23422
  user_id: userId,
23304
23423
  title,
23305
23424
  });
@@ -23329,7 +23448,7 @@ class Conversation {
23329
23448
  sendMessageTextChunk(text) {
23330
23449
  return this.client.request(`send_text_chat`, {
23331
23450
  channel_id: this.channelId,
23332
- conversation_id: this.id,
23451
+ conversation_id: this.conversationId,
23333
23452
  text,
23334
23453
  });
23335
23454
  }
@@ -23466,7 +23585,7 @@ class Client extends EventEmitter {
23466
23585
  call.answeredAt = c.answered_at || 0;
23467
23586
  call.bridgedAt = c.bridged_at || 0;
23468
23587
  call.hangupAt = c.hangup_at || 0;
23469
- call.reportingAt = c.reporting_at || 0;
23588
+ // call.reportingAt = c.reporting_at || 0
23470
23589
  if (c.task) {
23471
23590
  call.task = new Task(this, {
23472
23591
  attempt_id: c.task.attempt_id,
@@ -23476,6 +23595,14 @@ class Client extends EventEmitter {
23476
23595
  }, c.task // todo add app_id
23477
23596
  );
23478
23597
  call.queue.reporting = 'true';
23598
+ if (c.leaving_at && c.task.processing_sec) {
23599
+ call.task.startProcessingAt = c.leaving_at;
23600
+ call.task.setProcessing({
23601
+ sec: c.task.processing_sec || 0,
23602
+ timeout: Date.now() - c.leaving_at + (c.task.processing_sec || 0) * 1000,
23603
+ renewal_sec: c.task.processing_renewal_sec || 0,
23604
+ });
23605
+ }
23479
23606
  }
23480
23607
  this.callStore.set(call.id, call);
23481
23608
  }
@@ -23491,6 +23618,26 @@ class Client extends EventEmitter {
23491
23618
  const messages = conv.messages.reverse();
23492
23619
  const c = new Conversation(this, conv.id, conv.title, conv.members, messages, conv.variables);
23493
23620
  c.createdAt = conv.created_at;
23621
+ c.closedAt = conv.closed_at;
23622
+ if (conv.task) {
23623
+ c.task = new Task(this, {
23624
+ attempt_id: conv.task.attempt_id,
23625
+ channel: conv.task.channel,
23626
+ status: conv.task.status,
23627
+ timestamp: Date.now(),
23628
+ }, conv.task // todo add app_id
23629
+ );
23630
+ if (conv.leaving_at && conv.task.processing_sec) {
23631
+ c.task.startProcessingAt = conv.leaving_at;
23632
+ c.task.setProcessing({
23633
+ sec: conv.task.processing_sec || 0,
23634
+ timeout: Date.now() -
23635
+ conv.leaving_at +
23636
+ (conv.task.processing_sec || 0) * 1000,
23637
+ renewal_sec: conv.task.processing_renewal_sec || 0,
23638
+ });
23639
+ }
23640
+ }
23494
23641
  if (conv.invite_id) {
23495
23642
  c.setInvite(conv.invite_id, conv.created_at);
23496
23643
  }
@@ -23990,7 +24137,7 @@ class Client extends EventEmitter {
23990
24137
  break;
23991
24138
  case ChatActions.Joined:
23992
24139
  const joined = event.data;
23993
- conversation = this.conversationById(joined.conversation_id);
24140
+ conversation = this.conversationById(joined.member.id);
23994
24141
  if (conversation) {
23995
24142
  conversation.setAnswered(joined.member.id, timestamp, joined.member);
23996
24143
  }
@@ -23998,17 +24145,38 @@ class Client extends EventEmitter {
23998
24145
  case ChatActions.Message:
23999
24146
  const message = event.data;
24000
24147
  message.timestamp = timestamp;
24001
- conversation = this.conversationById(message.conversation_id);
24148
+ // fixme
24149
+ for (const v of this.allConversations()) {
24150
+ if (!v.closedAt && v.membersId.indexOf(message.channel_id) > -1) {
24151
+ conversation = v;
24152
+ }
24153
+ }
24002
24154
  if (conversation) {
24003
24155
  conversation.newMessage(message);
24004
24156
  }
24005
24157
  break;
24006
24158
  case ChatActions.Close:
24159
+ const c = event.data;
24160
+ // fixme
24161
+ for (const v of this.allConversations()) {
24162
+ if (!v.closedAt && v.membersId.indexOf(c.from_channel_id) > -1) {
24163
+ conversation = v;
24164
+ }
24165
+ }
24166
+ if (conversation) {
24167
+ conversation.setClosed(timestamp);
24168
+ }
24169
+ break;
24007
24170
  case ChatActions.Leave:
24171
+ const l = event.data;
24172
+ conversation = this.conversationById(l.leaved_channel_id);
24173
+ if (conversation) {
24174
+ conversation.setClosed(timestamp);
24175
+ }
24176
+ break;
24008
24177
  case ChatActions.Decline:
24009
- // TODO leave & CLOSE:
24010
24178
  const e = event.data;
24011
- conversation = this.conversationById(e.conversation_id);
24179
+ conversation = this.conversationById(e.invite_id);
24012
24180
  if (conversation) {
24013
24181
  conversation.setClosed(timestamp);
24014
24182
  }