@webex/internal-plugin-conversation 3.0.0-beta.15 → 3.0.0-beta.16

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.
@@ -1,138 +1,78 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$keys = require("@babel/runtime-corejs2/core-js/object/keys");
4
-
5
4
  var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
6
-
7
5
  var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
8
-
9
6
  var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
10
-
11
7
  var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
12
-
13
8
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
14
-
15
9
  var _Array$from = require("@babel/runtime-corejs2/core-js/array/from");
16
-
17
10
  var _Symbol = require("@babel/runtime-corejs2/core-js/symbol");
18
-
19
11
  var _Symbol$iterator = require("@babel/runtime-corejs2/core-js/symbol/iterator");
20
-
21
12
  var _Array$isArray = require("@babel/runtime-corejs2/core-js/array/is-array");
22
-
23
13
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
24
-
25
14
  _Object$defineProperty(exports, "__esModule", {
26
15
  value: true
27
16
  });
28
-
29
17
  exports.default = void 0;
30
-
31
18
  var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
32
-
33
19
  var _map2 = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/map"));
34
-
35
20
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
36
-
37
21
  var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
38
-
39
22
  var _assign = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/assign"));
40
-
41
23
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
42
-
43
24
  var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/typeof"));
44
-
45
25
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
46
-
47
26
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
48
-
49
27
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
50
-
51
28
  var _awaitAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/awaitAsyncGenerator"));
52
-
53
29
  var _wrapAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/wrapAsyncGenerator"));
54
-
55
30
  var _uniq2 = _interopRequireDefault(require("lodash/uniq"));
56
-
57
31
  var _pick2 = _interopRequireDefault(require("lodash/pick"));
58
-
59
32
  var _omit2 = _interopRequireDefault(require("lodash/omit"));
60
-
61
33
  var _merge2 = _interopRequireDefault(require("lodash/merge"));
62
-
63
34
  var _map3 = _interopRequireDefault(require("lodash/map"));
64
-
65
35
  var _last2 = _interopRequireDefault(require("lodash/last"));
66
-
67
36
  var _isString2 = _interopRequireDefault(require("lodash/isString"));
68
-
69
37
  var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
70
-
71
38
  var _isArray2 = _interopRequireDefault(require("lodash/isArray"));
72
-
73
39
  var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
74
-
75
40
  var _cloneDeepWith2 = _interopRequireDefault(require("lodash/cloneDeepWith"));
76
-
77
41
  var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
78
-
79
42
  var _querystring = _interopRequireDefault(require("querystring"));
80
-
81
43
  var _events = require("events");
82
-
83
44
  var _hmacSha = _interopRequireDefault(require("crypto-js/hmac-sha256"));
84
-
85
45
  var _encHex = _interopRequireDefault(require("crypto-js/enc-hex"));
86
-
87
46
  var _common = require("@webex/common");
88
-
89
47
  var _webexCore = require("@webex/webex-core");
90
-
91
48
  var _helperImage = require("@webex/helper-image");
92
-
93
49
  var _uuid = _interopRequireDefault(require("uuid"));
94
-
95
50
  var _convoError = require("./convo-error");
96
-
97
51
  var _shareActivity = _interopRequireDefault(require("./share-activity"));
98
-
99
52
  var _activityThreadOrdering = require("./activity-thread-ordering");
100
-
101
53
  var _activities = require("./activities");
102
-
103
54
  var _constants = require("./constants");
104
-
105
55
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && o[_Symbol$iterator] || o["@@iterator"]; if (!it) { if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
106
-
107
56
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
108
-
109
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
110
-
57
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
111
58
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
112
-
113
59
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
114
-
115
60
  var CLUSTER_SERVICE = process.env.WEBEX_CONVERSATION_CLUSTER_SERVICE || _constants.DEFAULT_CLUSTER_SERVICE;
116
61
  var DEFAULT_CLUSTER_IDENTIFIER = process.env.WEBEX_CONVERSATION_DEFAULT_CLUSTER || "".concat(_constants.DEFAULT_CLUSTER, ":").concat(CLUSTER_SERVICE);
117
62
  var idToUrl = new _map2.default();
118
-
119
63
  var getConvoLimit = function getConvoLimit() {
120
64
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
121
65
  var limit;
122
-
123
66
  if (options.conversationsLimit) {
124
67
  limit = {
125
68
  value: options.conversationsLimit,
126
69
  name: 'conversationsLimit'
127
70
  };
128
71
  }
129
-
130
72
  return limit;
131
73
  };
132
-
133
74
  var Conversation = _webexCore.WebexPlugin.extend({
134
75
  namespace: 'Conversation',
135
-
136
76
  /**
137
77
  * @param {String} cluster the cluster containing the id
138
78
  * @param {UUID} [id] the id of the conversation.
@@ -141,29 +81,25 @@ var Conversation = _webexCore.WebexPlugin.extend({
141
81
  */
142
82
  getUrlFromClusterId: function getUrlFromClusterId() {
143
83
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
144
- _ref$cluster = _ref.cluster,
145
- cluster = _ref$cluster === void 0 ? 'us' : _ref$cluster,
146
- id = _ref.id;
147
-
148
- var clusterId = cluster === 'us' ? DEFAULT_CLUSTER_IDENTIFIER : cluster; // Determine if cluster has service name (non-US clusters from hydra do not)
84
+ _ref$cluster = _ref.cluster,
85
+ cluster = _ref$cluster === void 0 ? 'us' : _ref$cluster,
86
+ id = _ref.id;
87
+ var clusterId = cluster === 'us' ? DEFAULT_CLUSTER_IDENTIFIER : cluster;
149
88
 
89
+ // Determine if cluster has service name (non-US clusters from hydra do not)
150
90
  if (clusterId.split(':').length < 4) {
151
91
  // Add Service to cluster identifier
152
92
  clusterId = "".concat(cluster, ":").concat(CLUSTER_SERVICE);
153
93
  }
154
-
155
94
  var _ref2 = this.webex.internal.services.getServiceFromClusterId({
156
- clusterId: clusterId
157
- }) || {},
158
- url = _ref2.url;
159
-
95
+ clusterId: clusterId
96
+ }) || {},
97
+ url = _ref2.url;
160
98
  if (!url) {
161
99
  throw Error("Could not find service for cluster [".concat(cluster, "]"));
162
100
  }
163
-
164
101
  return id ? "".concat(url, "/conversations/").concat(id) : url;
165
102
  },
166
-
167
103
  /**
168
104
  * @param {Object} conversation
169
105
  * @param {Object} object
@@ -172,17 +108,13 @@ var Conversation = _webexCore.WebexPlugin.extend({
172
108
  */
173
109
  acknowledge: function acknowledge(conversation, object, activity) {
174
110
  var _this2 = this;
175
-
176
111
  var url = this.getConvoUrl(conversation);
177
-
178
112
  var convoWithUrl = _objectSpread(_objectSpread({}, conversation), {}, {
179
113
  url: url
180
114
  });
181
-
182
115
  if (!(0, _isObject2.default)(object)) {
183
116
  return _promise.default.reject(new Error('`object` must be an object'));
184
117
  }
185
-
186
118
  return this.prepare(activity, {
187
119
  verb: 'acknowledge',
188
120
  target: this.prepareConversation(convoWithUrl),
@@ -195,7 +127,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
195
127
  return _this2.submit(a);
196
128
  });
197
129
  },
198
-
199
130
  /**
200
131
  * Adds a participant to a conversation
201
132
  * @param {Object} conversation
@@ -207,13 +138,10 @@ var Conversation = _webexCore.WebexPlugin.extend({
207
138
  */
208
139
  add: function add(conversation, participant, activity) {
209
140
  var _this3 = this;
210
-
211
141
  var url = this.getConvoUrl(conversation);
212
-
213
142
  var convoWithUrl = _objectSpread(_objectSpread({}, conversation), {}, {
214
143
  url: url
215
144
  });
216
-
217
145
  return this.webex.internal.user.asUUID(participant, {
218
146
  create: true
219
147
  }).then(function (id) {
@@ -235,7 +163,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
235
163
  });
236
164
  });
237
165
  },
238
-
239
166
  /**
240
167
  * Creates a conversation
241
168
  * @param {Object} params
@@ -257,17 +184,15 @@ var Conversation = _webexCore.WebexPlugin.extend({
257
184
  */
258
185
  create: function create(params) {
259
186
  var _this4 = this;
260
-
261
187
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
262
-
263
188
  if (!params.participants || params.participants.length === 0) {
264
189
  return _promise.default.reject(new Error('`params.participants` is required'));
265
190
  }
266
-
267
191
  return _promise.default.all(params.participants.map(function (participant) {
268
192
  return _this4.webex.internal.user.asUUID(participant, {
269
193
  create: true
270
- }) // eslint-disable-next-line arrow-body-style
194
+ })
195
+ // eslint-disable-next-line arrow-body-style
271
196
  .catch(function (err) {
272
197
  return options.allowPartialCreation ? undefined : _promise.default.reject(err);
273
198
  });
@@ -277,35 +202,30 @@ var Conversation = _webexCore.WebexPlugin.extend({
277
202
  var validParticipants = participants.filter(function (participant) {
278
203
  return participant;
279
204
  });
280
- params.participants = validParticipants; // check if original participants list was to create a 1:1
205
+ params.participants = validParticipants;
281
206
 
207
+ // check if original participants list was to create a 1:1
282
208
  if (participants.length === 2 && !(options && options.forceGrouped)) {
283
209
  if (!params.participants[1]) {
284
210
  return _promise.default.reject(new _convoError.InvalidUserCreation());
285
211
  }
286
-
287
212
  if (options.skipOneOnOneFetch) {
288
213
  return _this4._createOneOnOne(params);
289
214
  }
290
-
291
215
  return _this4._maybeCreateOneOnOneThenPost(params, options);
292
216
  }
293
-
294
217
  return _this4._createGrouped(params, options);
295
218
  }).then(function (c) {
296
219
  idToUrl.set(c.id, c.url);
297
-
298
220
  if (!params.files) {
299
221
  return c;
300
222
  }
301
-
302
223
  return _this4.webex.internal.conversation.share(c, params.files).then(function (a) {
303
224
  c.activities.items.push(a);
304
225
  return c;
305
226
  });
306
227
  });
307
228
  },
308
-
309
229
  /**
310
230
  * @private
311
231
  * generate a deterministic HMAC for a reaction
@@ -316,23 +236,21 @@ var Conversation = _webexCore.WebexPlugin.extend({
316
236
  createReactionHmac: function createReactionHmac(displayName, parent) {
317
237
  // not using webex.internal.encryption.getKey() because the JWK it returns does not have a 'k'
318
238
  // property. we need jwk.k to correctly generate the HMAC
239
+
319
240
  return this.webex.internal.encryption.unboundedStorage.get(parent.encryptionKeyUrl).then(function (keyString) {
320
- var key = JSON.parse(keyString); // when we stringify this object, keys must be in this order to generate same HMAC as
241
+ var key = JSON.parse(keyString);
242
+ // when we stringify this object, keys must be in this order to generate same HMAC as
321
243
  // desktop clients
322
-
323
244
  var formatjwk = {
324
245
  k: key.jwk.k,
325
246
  kid: key.jwk.kid,
326
247
  kty: key.jwk.kty
327
248
  };
328
249
  var source = "".concat((0, _stringify.default)(formatjwk)).concat(parent.id).concat(displayName);
329
-
330
250
  var hmac = _encHex.default.stringify((0, _hmacSha.default)(source, parent.id));
331
-
332
251
  return _promise.default.resolve(hmac);
333
252
  });
334
253
  },
335
-
336
254
  /**
337
255
  * @typedef {Object} ReactionPayload
338
256
  * @property {Object} actor
@@ -349,7 +267,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
349
267
  * @property {string} object.displayName must be 'celebrate', 'heart', 'thumbsup', 'smiley', 'haha', 'confused', 'sad'
350
268
  * @property {string} object.hmac
351
269
  */
352
-
353
270
  /**
354
271
  * @private
355
272
  * send add or delete reaction to convo service
@@ -360,17 +277,13 @@ var Conversation = _webexCore.WebexPlugin.extend({
360
277
  */
361
278
  sendReaction: function sendReaction(conversation, reactionPayload) {
362
279
  var _this5 = this;
363
-
364
280
  var url = this.getConvoUrl(conversation);
365
-
366
281
  var convoWithUrl = _objectSpread(_objectSpread({}, conversation), {}, {
367
282
  url: url
368
283
  });
369
-
370
284
  if (!(0, _isObject2.default)(reactionPayload)) {
371
285
  return _promise.default.reject(new Error('`object` must be an object'));
372
286
  }
373
-
374
287
  return this.prepare(reactionPayload, {
375
288
  target: this.prepareConversation(convoWithUrl),
376
289
  object: (0, _pick2.default)(reactionPayload, 'id', 'url', 'objectType')
@@ -378,7 +291,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
378
291
  return _this5.submit(act);
379
292
  });
380
293
  },
381
-
382
294
  /**
383
295
  * delete a reaction
384
296
  * @param {Object} conversation
@@ -404,7 +316,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
404
316
  };
405
317
  return this.sendReaction(conversation, deleteReactionPayload);
406
318
  },
407
-
408
319
  /**
409
320
  * create a reaction
410
321
  * @param {Object} conversation
@@ -414,7 +325,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
414
325
  */
415
326
  addReaction: function addReaction(conversation, displayName, activity) {
416
327
  var _this6 = this;
417
-
418
328
  return this.createReactionHmac(displayName, activity).then(function (hmac) {
419
329
  var addReactionPayload = {
420
330
  actor: {
@@ -440,7 +350,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
440
350
  return _this6.sendReaction(conversation, addReactionPayload);
441
351
  });
442
352
  },
443
-
444
353
  /**
445
354
  * delete content
446
355
  * @param {Object} conversation
@@ -450,23 +359,20 @@ var Conversation = _webexCore.WebexPlugin.extend({
450
359
  */
451
360
  delete: function _delete(conversation, object, activity) {
452
361
  var _this7 = this;
453
-
454
362
  var url = this.getConvoUrl(conversation);
455
-
456
363
  var convoWithUrl = _objectSpread(_objectSpread({}, conversation), {}, {
457
364
  url: url
458
365
  });
459
-
460
366
  if (!(0, _isObject2.default)(object)) {
461
367
  return _promise.default.reject(new Error('`object` must be an object'));
462
368
  }
463
-
464
369
  var request = {
465
370
  verb: 'delete',
466
371
  target: this.prepareConversation(convoWithUrl),
467
372
  object: (0, _pick2.default)(object, 'id', 'url', 'objectType')
468
- }; // Deleting meeting container requires KMS message
373
+ };
469
374
 
375
+ // Deleting meeting container requires KMS message
470
376
  if (object.object.objectType === 'meetingContainer') {
471
377
  // It's building a string uri + "/authorizations?authId=" + id, where uri is the meeting container's KRO URL, and id is the conversation's KRO URL.
472
378
  request.target.kmsResourceObjectUrl = object.object.kmsResourceObjectUrl;
@@ -477,12 +383,10 @@ var Conversation = _webexCore.WebexPlugin.extend({
477
383
  }))
478
384
  };
479
385
  }
480
-
481
386
  return this.prepare(activity, request).then(function (a) {
482
387
  return _this7.submit(a);
483
388
  });
484
389
  },
485
-
486
390
  /**
487
391
  * Downloads the file specified in item.scr or item.url
488
392
  * @param {Object} item
@@ -495,12 +399,10 @@ var Conversation = _webexCore.WebexPlugin.extend({
495
399
  */
496
400
  download: function download(item) {
497
401
  var _this8 = this;
498
-
499
402
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
500
403
  var isEncrypted = Boolean(item.scr && item.scr.key);
501
404
  var shunt = new _events.EventEmitter();
502
405
  var promise;
503
-
504
406
  if (isEncrypted) {
505
407
  promise = this.webex.internal.encryption.download(item.scr, item.options);
506
408
  } else if (item.scr && item.scr.loc) {
@@ -508,36 +410,29 @@ var Conversation = _webexCore.WebexPlugin.extend({
508
410
  } else {
509
411
  promise = this._downloadUnencryptedFile(item.url, options);
510
412
  }
511
-
512
413
  promise = promise.on('progress', function () {
513
414
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
514
415
  args[_key] = arguments[_key];
515
416
  }
516
-
517
417
  return shunt.emit.apply(shunt, ['progress'].concat(args));
518
418
  }).then(function (res) {
519
419
  if (options.shouldNotAddExifData) {
520
420
  return res;
521
421
  }
522
-
523
422
  return (0, _helperImage.readExifData)(item, res);
524
423
  }).then(function (file) {
525
424
  _this8.logger.info('conversation: file downloaded');
526
-
527
425
  if (item.displayName && !file.name) {
528
426
  file.name = item.displayName;
529
427
  }
530
-
531
428
  if (!file.type && item.mimeType) {
532
429
  file.type = item.mimeType;
533
430
  }
534
-
535
431
  return file;
536
432
  });
537
433
  (0, _common.proxyEvents)(shunt, promise);
538
434
  return promise;
539
435
  },
540
-
541
436
  /**
542
437
  * Downloads an unencrypted file
543
438
  * @param {string} uri
@@ -557,7 +452,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
557
452
  (0, _common.proxyEvents)(options.download, promise);
558
453
  return promise;
559
454
  },
560
-
561
455
  /**
562
456
  * Helper method that expands a set of parameters into an activty object
563
457
  * @param {string} verb
@@ -572,29 +466,23 @@ var Conversation = _webexCore.WebexPlugin.extend({
572
466
  objectType: 'activity',
573
467
  verb: verb
574
468
  };
575
-
576
469
  if (!actor) {
577
470
  actor = this.webex.internal.device.userId;
578
471
  }
579
-
580
472
  if ((0, _isString2.default)(actor)) {
581
473
  activity.actor = {
582
474
  objectType: 'person',
583
475
  id: actor
584
476
  };
585
477
  }
586
-
587
478
  if (object) {
588
479
  activity.object = object;
589
480
  }
590
-
591
481
  if (target) {
592
482
  activity.target = target;
593
483
  }
594
-
595
484
  return activity;
596
485
  },
597
-
598
486
  /**
599
487
  * Gets an array of activities with an array of activity URLS
600
488
  * @param {Array} activityUrls
@@ -607,14 +495,12 @@ var Conversation = _webexCore.WebexPlugin.extend({
607
495
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
608
496
  var cluster;
609
497
  var url;
610
-
611
498
  if (typeof options === 'string') {
612
499
  cluster = options;
613
500
  } else {
614
501
  cluster = options.cluster;
615
502
  url = options.url;
616
503
  }
617
-
618
504
  var resource = 'bulk_activities_fetch';
619
505
  var params = {
620
506
  method: 'POST',
@@ -622,7 +508,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
622
508
  activityUrls: activityUrls
623
509
  }
624
510
  };
625
-
626
511
  if (url) {
627
512
  var uri = "".concat(url, "/").concat(resource);
628
513
  (0, _assign.default)(params, {
@@ -632,7 +517,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
632
517
  var _uri = "".concat(this.getUrlFromClusterId({
633
518
  cluster: cluster
634
519
  }), "/").concat(resource);
635
-
636
520
  (0, _assign.default)(params, {
637
521
  uri: _uri
638
522
  });
@@ -642,10 +526,8 @@ var Conversation = _webexCore.WebexPlugin.extend({
642
526
  resource: resource
643
527
  });
644
528
  }
645
-
646
529
  return this.webex.request(params).then(function (res) {
647
530
  var activitiesArr = [];
648
-
649
531
  if (res.body.multistatus) {
650
532
  res.body.multistatus.forEach(function (statusData) {
651
533
  if (statusData.status === '200' && statusData.data && statusData.data.activity) {
@@ -653,11 +535,9 @@ var Conversation = _webexCore.WebexPlugin.extend({
653
535
  }
654
536
  });
655
537
  }
656
-
657
538
  return activitiesArr;
658
539
  });
659
540
  },
660
-
661
541
  /**
662
542
  * Fetches a single conversation
663
543
  * @param {Object} conversation
@@ -669,17 +549,14 @@ var Conversation = _webexCore.WebexPlugin.extend({
669
549
  */
670
550
  get: function get(conversation) {
671
551
  var _this9 = this;
672
-
673
552
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
674
553
  var user = conversation.user;
675
554
  var uri;
676
-
677
555
  try {
678
556
  uri = !user ? this.getConvoUrl(conversation) : '';
679
557
  } catch (err) {
680
558
  return _promise.default.reject(Error(err));
681
559
  }
682
-
683
560
  var params = {
684
561
  qs: _objectSpread({
685
562
  uuidEntryFormat: true,
@@ -689,15 +566,15 @@ var Conversation = _webexCore.WebexPlugin.extend({
689
566
  includeParticipants: false
690
567
  }, (0, _omit2.default)(options, 'id', 'user', 'url')),
691
568
  disableTransform: options.disableTransform
692
- }; // Default behavior is to set includeParticipants=false,
569
+ };
570
+
571
+ // Default behavior is to set includeParticipants=false,
693
572
  // which makes the payload lighter by removing participant info.
694
573
  // If the caller explicitly sets the participantAckFilter or
695
574
  // participantsLimit, we don't want that default setting.
696
-
697
575
  if ('participantAckFilter' in options || 'participantsLimit' in options) {
698
576
  delete params.qs.includeParticipants;
699
577
  }
700
-
701
578
  return _promise.default.resolve(user ? this.webex.internal.user.asUUID(user) : null).then(function (userId) {
702
579
  if (userId) {
703
580
  (0, _assign.default)(params, {
@@ -707,21 +584,17 @@ var Conversation = _webexCore.WebexPlugin.extend({
707
584
  } else {
708
585
  params.uri = uri;
709
586
  }
710
-
711
587
  return _this9.request(params);
712
588
  }).then((0, _common.tap)(function (_ref3) {
713
589
  var body = _ref3.body;
714
590
  var id = body.id,
715
- url = body.url;
716
-
591
+ url = body.url;
717
592
  _this9._recordUUIDs(body);
718
-
719
593
  idToUrl.set(id, url);
720
594
  })).then(function (res) {
721
595
  return res.body;
722
596
  });
723
597
  },
724
-
725
598
  /**
726
599
  * Leaves the conversation or removes the specified user from the specified
727
600
  * conversation
@@ -735,16 +608,13 @@ var Conversation = _webexCore.WebexPlugin.extend({
735
608
  */
736
609
  leave: function leave(conversation, participant, activity) {
737
610
  var _this10 = this;
738
-
739
611
  var convoWithUrl = _objectSpread(_objectSpread({}, conversation), {}, {
740
612
  url: this.getConvoUrl(conversation)
741
613
  });
742
-
743
614
  return _promise.default.resolve().then(function () {
744
615
  if (!participant) {
745
616
  participant = _this10.webex.internal.device.userId;
746
617
  }
747
-
748
618
  return _this10.webex.internal.user.asUUID(participant).then(function (id) {
749
619
  return _this10.prepare(activity, {
750
620
  verb: 'leave',
@@ -765,7 +635,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
765
635
  return _this10.submit(a);
766
636
  });
767
637
  },
768
-
769
638
  /**
770
639
  * Lists a set of conversations. By default does not fetch activities or
771
640
  * participants
@@ -788,8 +657,7 @@ var Conversation = _webexCore.WebexPlugin.extend({
788
657
  limit: getConvoLimit(options)
789
658
  }).then(function (results) {
790
659
  var _iterator = _createForOfIteratorHelper(results),
791
- _step;
792
-
660
+ _step;
793
661
  try {
794
662
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
795
663
  var convo = _step.value;
@@ -800,11 +668,9 @@ var Conversation = _webexCore.WebexPlugin.extend({
800
668
  } finally {
801
669
  _iterator.f();
802
670
  }
803
-
804
671
  return results;
805
672
  });
806
673
  },
807
-
808
674
  /**
809
675
  * Paginates through a set of conversations. By default does not fetch activities or
810
676
  * participants
@@ -819,81 +685,67 @@ var Conversation = _webexCore.WebexPlugin.extend({
819
685
  */
820
686
  paginate: function paginate() {
821
687
  var _arguments = arguments,
822
- _this11 = this;
823
-
688
+ _this11 = this;
824
689
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
825
690
  var options, queryOptions, reqOptions;
826
691
  return _regenerator.default.wrap(function _callee$(_context) {
827
- while (1) {
828
- switch (_context.prev = _context.next) {
829
- case 0:
830
- options = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {};
831
-
832
- if (!options.page) {
833
- _context.next = 5;
834
- break;
835
- }
836
-
837
- if (!(!options.page.links || !options.page.links.next)) {
838
- _context.next = 4;
839
- break;
840
- }
841
-
842
- throw new Error('No link to follow for the provided page');
843
-
844
- case 4:
845
- return _context.abrupt("return", _this11.request({
846
- url: options.page.links.next
847
- }).then(function (res) {
848
- return {
849
- page: new _webexCore.Page(res, _this11.webex)
850
- };
851
- }));
852
-
853
- case 5:
854
- // No page - so this is the first request to kick off the pagination process
855
- queryOptions = _objectSpread({
856
- personRefresh: true,
857
- uuidEntryFormat: true,
858
- activitiesLimit: 0,
859
- participantsLimit: 0,
860
- paginate: true
861
- }, (0, _omit2.default)(options, ['deferDecrypt', 'url']));
862
- reqOptions = {
863
- qs: queryOptions,
864
- deferDecrypt: options.deferDecrypt,
865
- limit: getConvoLimit(options)
866
- }; // if options.url is present we likely received one or more additional urls due to federation. In this case
867
- // we need to initialize pagination against that url instead of the default home cluster
868
-
869
- if (options.url) {
870
- reqOptions.uri = "".concat(options.url, "/conversations");
871
- } else {
872
- reqOptions.service = 'conversation';
873
- reqOptions.resource = 'conversations';
692
+ while (1) switch (_context.prev = _context.next) {
693
+ case 0:
694
+ options = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {};
695
+ if (!options.page) {
696
+ _context.next = 5;
697
+ break;
698
+ }
699
+ if (!(!options.page.links || !options.page.links.next)) {
700
+ _context.next = 4;
701
+ break;
702
+ }
703
+ throw new Error('No link to follow for the provided page');
704
+ case 4:
705
+ return _context.abrupt("return", _this11.request({
706
+ url: options.page.links.next
707
+ }).then(function (res) {
708
+ return {
709
+ page: new _webexCore.Page(res, _this11.webex)
710
+ };
711
+ }));
712
+ case 5:
713
+ // No page - so this is the first request to kick off the pagination process
714
+ queryOptions = _objectSpread({
715
+ personRefresh: true,
716
+ uuidEntryFormat: true,
717
+ activitiesLimit: 0,
718
+ participantsLimit: 0,
719
+ paginate: true
720
+ }, (0, _omit2.default)(options, ['deferDecrypt', 'url']));
721
+ reqOptions = {
722
+ qs: queryOptions,
723
+ deferDecrypt: options.deferDecrypt,
724
+ limit: getConvoLimit(options)
725
+ }; // if options.url is present we likely received one or more additional urls due to federation. In this case
726
+ // we need to initialize pagination against that url instead of the default home cluster
727
+ if (options.url) {
728
+ reqOptions.uri = "".concat(options.url, "/conversations");
729
+ } else {
730
+ reqOptions.service = 'conversation';
731
+ reqOptions.resource = 'conversations';
732
+ }
733
+ return _context.abrupt("return", _this11.request(reqOptions).then(function (res) {
734
+ var response = {
735
+ page: new _webexCore.Page(res, _this11.webex)
736
+ };
737
+ if (res.body && res.body.additionalUrls) {
738
+ response.additionalUrls = res.body.additionalUrls;
874
739
  }
875
-
876
- return _context.abrupt("return", _this11.request(reqOptions).then(function (res) {
877
- var response = {
878
- page: new _webexCore.Page(res, _this11.webex)
879
- };
880
-
881
- if (res.body && res.body.additionalUrls) {
882
- response.additionalUrls = res.body.additionalUrls;
883
- }
884
-
885
- return response;
886
- }));
887
-
888
- case 9:
889
- case "end":
890
- return _context.stop();
891
- }
740
+ return response;
741
+ }));
742
+ case 9:
743
+ case "end":
744
+ return _context.stop();
892
745
  }
893
746
  }, _callee);
894
747
  }))();
895
748
  },
896
-
897
749
  /**
898
750
  * Lists the conversations the current user has left. By default does not
899
751
  * fetch activities or participants
@@ -908,8 +760,7 @@ var Conversation = _webexCore.WebexPlugin.extend({
908
760
  limit: getConvoLimit(options)
909
761
  }).then(function (results) {
910
762
  var _iterator2 = _createForOfIteratorHelper(results),
911
- _step2;
912
-
763
+ _step2;
913
764
  try {
914
765
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
915
766
  var convo = _step2.value;
@@ -920,11 +771,9 @@ var Conversation = _webexCore.WebexPlugin.extend({
920
771
  } finally {
921
772
  _iterator2.f();
922
773
  }
923
-
924
774
  return results;
925
775
  });
926
776
  },
927
-
928
777
  /**
929
778
  * List activities for the specified conversation
930
779
  * @param {Object} options
@@ -936,7 +785,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
936
785
  resource: 'activities'
937
786
  }));
938
787
  },
939
-
940
788
  /**
941
789
  * @typedef QueryOptions
942
790
  * @param {number} [limit] The limit of child activities that can be returned per request
@@ -948,7 +796,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
948
796
  * @param {string} [activityType] The type of children to return the parents of, a null value here returns parents of all types of children.
949
797
  * The value is one of 'reply', 'edit', 'cardAction', 'reaction', 'reactionSummary', 'reactionSelfSummary'
950
798
  */
951
-
952
799
  /**
953
800
  * Get all parent ids for a conversation.
954
801
  * @param {string} conversationUrl conversation URL.
@@ -957,34 +804,28 @@ var Conversation = _webexCore.WebexPlugin.extend({
957
804
  */
958
805
  listParentActivityIds: function listParentActivityIds(conversationUrl, query) {
959
806
  var _this12 = this;
960
-
961
807
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
962
808
  var params, response;
963
809
  return _regenerator.default.wrap(function _callee2$(_context2) {
964
- while (1) {
965
- switch (_context2.prev = _context2.next) {
966
- case 0:
967
- params = {
968
- method: 'GET',
969
- url: "".concat(conversationUrl, "/parents"),
970
- qs: query
971
- };
972
- _context2.next = 3;
973
- return _this12.request(params);
974
-
975
- case 3:
976
- response = _context2.sent;
977
- return _context2.abrupt("return", response.body);
978
-
979
- case 5:
980
- case "end":
981
- return _context2.stop();
982
- }
810
+ while (1) switch (_context2.prev = _context2.next) {
811
+ case 0:
812
+ params = {
813
+ method: 'GET',
814
+ url: "".concat(conversationUrl, "/parents"),
815
+ qs: query
816
+ };
817
+ _context2.next = 3;
818
+ return _this12.request(params);
819
+ case 3:
820
+ response = _context2.sent;
821
+ return _context2.abrupt("return", response.body);
822
+ case 5:
823
+ case "end":
824
+ return _context2.stop();
983
825
  }
984
826
  }, _callee2);
985
827
  }))();
986
828
  },
987
-
988
829
  /**
989
830
  * Returns a list of _all_ child activities for a given parentId within a given conversation
990
831
  * @param {object} [options = {}]
@@ -995,70 +836,56 @@ var Conversation = _webexCore.WebexPlugin.extend({
995
836
  */
996
837
  listAllChildActivitiesByParentId: function listAllChildActivitiesByParentId() {
997
838
  var _arguments2 = arguments,
998
- _this13 = this;
999
-
839
+ _this13 = this;
1000
840
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
1001
841
  var options, conversationUrl, activityParentId, query, activityType, initialResponse, page, items, _iterator3, _step3, activity;
1002
-
1003
842
  return _regenerator.default.wrap(function _callee3$(_context3) {
1004
- while (1) {
1005
- switch (_context3.prev = _context3.next) {
1006
- case 0:
1007
- options = _arguments2.length > 0 && _arguments2[0] !== undefined ? _arguments2[0] : {};
1008
- conversationUrl = options.conversationUrl, activityParentId = options.activityParentId, query = options.query;
1009
- activityType = query.activityType;
1010
- _context3.next = 5;
1011
- return _this13.listChildActivitiesByParentId(conversationUrl, activityParentId, activityType, query);
1012
-
1013
- case 5:
1014
- initialResponse = _context3.sent;
1015
- page = new _webexCore.Page(initialResponse, _this13.webex);
1016
- items = (0, _toConsumableArray2.default)(page.items);
1017
-
1018
- case 8:
1019
- if (!page.hasNext()) {
1020
- _context3.next = 16;
1021
- break;
1022
- }
1023
-
1024
- _context3.next = 11;
1025
- return page.next();
1026
-
1027
- case 11:
1028
- page = _context3.sent;
1029
- _iterator3 = _createForOfIteratorHelper(page);
1030
-
1031
- try {
1032
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1033
- activity = _step3.value;
1034
- items.push(activity);
1035
- }
1036
- } catch (err) {
1037
- _iterator3.e(err);
1038
- } finally {
1039
- _iterator3.f();
1040
- }
1041
-
1042
- _context3.next = 8;
843
+ while (1) switch (_context3.prev = _context3.next) {
844
+ case 0:
845
+ options = _arguments2.length > 0 && _arguments2[0] !== undefined ? _arguments2[0] : {};
846
+ conversationUrl = options.conversationUrl, activityParentId = options.activityParentId, query = options.query;
847
+ activityType = query.activityType;
848
+ _context3.next = 5;
849
+ return _this13.listChildActivitiesByParentId(conversationUrl, activityParentId, activityType, query);
850
+ case 5:
851
+ initialResponse = _context3.sent;
852
+ page = new _webexCore.Page(initialResponse, _this13.webex);
853
+ items = (0, _toConsumableArray2.default)(page.items);
854
+ case 8:
855
+ if (!page.hasNext()) {
856
+ _context3.next = 16;
1043
857
  break;
1044
-
1045
- case 16:
1046
- // reverse list if needed (see _list for precedent)
1047
- if (items.length && (0, _last2.default)(items).published < items[0].published) {
1048
- items.reverse();
858
+ }
859
+ _context3.next = 11;
860
+ return page.next();
861
+ case 11:
862
+ page = _context3.sent;
863
+ _iterator3 = _createForOfIteratorHelper(page);
864
+ try {
865
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
866
+ activity = _step3.value;
867
+ items.push(activity);
1049
868
  }
1050
-
1051
- return _context3.abrupt("return", items);
1052
-
1053
- case 18:
1054
- case "end":
1055
- return _context3.stop();
1056
- }
869
+ } catch (err) {
870
+ _iterator3.e(err);
871
+ } finally {
872
+ _iterator3.f();
873
+ }
874
+ _context3.next = 8;
875
+ break;
876
+ case 16:
877
+ // reverse list if needed (see _list for precedent)
878
+ if (items.length && (0, _last2.default)(items).published < items[0].published) {
879
+ items.reverse();
880
+ }
881
+ return _context3.abrupt("return", items);
882
+ case 18:
883
+ case "end":
884
+ return _context3.stop();
1057
885
  }
1058
886
  }, _callee3);
1059
887
  }))();
1060
888
  },
1061
-
1062
889
  /**
1063
890
  * Return a list of child activities with a given conversation, parentId and other constraints.
1064
891
  * @param {string} conversationUrl targeted conversation URL
@@ -1070,34 +897,29 @@ var Conversation = _webexCore.WebexPlugin.extend({
1070
897
  */
1071
898
  listChildActivitiesByParentId: function listChildActivitiesByParentId(conversationUrl, activityParentId, activityType) {
1072
899
  var _arguments3 = arguments,
1073
- _this14 = this;
1074
-
900
+ _this14 = this;
1075
901
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
1076
902
  var query, finalQuery, params;
1077
903
  return _regenerator.default.wrap(function _callee4$(_context4) {
1078
- while (1) {
1079
- switch (_context4.prev = _context4.next) {
1080
- case 0:
1081
- query = _arguments3.length > 3 && _arguments3[3] !== undefined ? _arguments3[3] : {};
1082
- finalQuery = _objectSpread(_objectSpread({}, query), {}, {
1083
- activityType: activityType
1084
- });
1085
- params = {
1086
- method: 'GET',
1087
- url: "".concat(conversationUrl, "/parents/").concat(activityParentId),
1088
- qs: finalQuery
1089
- };
1090
- return _context4.abrupt("return", _this14.request(params));
1091
-
1092
- case 4:
1093
- case "end":
1094
- return _context4.stop();
1095
- }
904
+ while (1) switch (_context4.prev = _context4.next) {
905
+ case 0:
906
+ query = _arguments3.length > 3 && _arguments3[3] !== undefined ? _arguments3[3] : {};
907
+ finalQuery = _objectSpread(_objectSpread({}, query), {}, {
908
+ activityType: activityType
909
+ });
910
+ params = {
911
+ method: 'GET',
912
+ url: "".concat(conversationUrl, "/parents/").concat(activityParentId),
913
+ qs: finalQuery
914
+ };
915
+ return _context4.abrupt("return", _this14.request(params));
916
+ case 4:
917
+ case "end":
918
+ return _context4.stop();
1096
919
  }
1097
920
  }, _callee4);
1098
921
  }))();
1099
922
  },
1100
-
1101
923
  /**
1102
924
  * Return an array of reactionSummary and reactionSelfSummary objects
1103
925
  * @param {string} conversationUrl targeted conversation URL
@@ -1107,38 +929,31 @@ var Conversation = _webexCore.WebexPlugin.extend({
1107
929
  */
1108
930
  getReactionSummaryByParentId: function getReactionSummaryByParentId(conversationUrl, activityParentId, query) {
1109
931
  var _this15 = this;
1110
-
1111
932
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
1112
933
  var _yield$_this15$reques, body, reactionObjects;
1113
-
1114
934
  return _regenerator.default.wrap(function _callee5$(_context5) {
1115
- while (1) {
1116
- switch (_context5.prev = _context5.next) {
1117
- case 0:
1118
- _context5.next = 2;
1119
- return _this15.request({
1120
- method: 'GET',
1121
- url: "".concat(conversationUrl, "/activities/").concat(activityParentId),
1122
- qs: query
1123
- });
1124
-
1125
- case 2:
1126
- _yield$_this15$reques = _context5.sent;
1127
- body = _yield$_this15$reques.body;
1128
- reactionObjects = body.children ? body.children.filter(function (child) {
1129
- return child.type === 'reactionSelfSummary' || child.type === 'reactionSummary';
1130
- }) : [];
1131
- return _context5.abrupt("return", reactionObjects);
1132
-
1133
- case 6:
1134
- case "end":
1135
- return _context5.stop();
1136
- }
935
+ while (1) switch (_context5.prev = _context5.next) {
936
+ case 0:
937
+ _context5.next = 2;
938
+ return _this15.request({
939
+ method: 'GET',
940
+ url: "".concat(conversationUrl, "/activities/").concat(activityParentId),
941
+ qs: query
942
+ });
943
+ case 2:
944
+ _yield$_this15$reques = _context5.sent;
945
+ body = _yield$_this15$reques.body;
946
+ reactionObjects = body.children ? body.children.filter(function (child) {
947
+ return child.type === 'reactionSelfSummary' || child.type === 'reactionSummary';
948
+ }) : [];
949
+ return _context5.abrupt("return", reactionObjects);
950
+ case 6:
951
+ case "end":
952
+ return _context5.stop();
1137
953
  }
1138
954
  }, _callee5);
1139
955
  }))();
1140
956
  },
1141
-
1142
957
  /**
1143
958
  * Lists activities in which the current user was mentioned
1144
959
  * @param {Object} options
@@ -1151,7 +966,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1151
966
  qs: (0, _omit2.default)(options, 'mentions')
1152
967
  });
1153
968
  },
1154
-
1155
969
  /**
1156
970
  * Mutes the mentions of a conversation
1157
971
  * @param {Conversation~ConversationObject} conversation
@@ -1163,7 +977,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1163
977
  tags: ['MENTION_NOTIFICATIONS_OFF']
1164
978
  }, activity);
1165
979
  },
1166
-
1167
980
  /**
1168
981
  * Mutes the messages of a conversation
1169
982
  * @param {Conversation~ConversationObject} conversation
@@ -1175,7 +988,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1175
988
  tags: ['MESSAGE_NOTIFICATIONS_OFF']
1176
989
  }, activity);
1177
990
  },
1178
-
1179
991
  /**
1180
992
  * Starts ignoring conversation
1181
993
  * @param {Conversation~ConversationObject} conversation
@@ -1187,7 +999,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1187
999
  tags: ['IGNORED']
1188
1000
  }, activity);
1189
1001
  },
1190
-
1191
1002
  /**
1192
1003
  * @param {Object} conversation
1193
1004
  * @param {Object} inputs
@@ -1197,13 +1008,10 @@ var Conversation = _webexCore.WebexPlugin.extend({
1197
1008
  */
1198
1009
  cardAction: function cardAction(conversation, inputs, parentActivity) {
1199
1010
  var _this16 = this;
1200
-
1201
1011
  var activity = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1202
-
1203
1012
  var convoWithUrl = _objectSpread(_objectSpread({}, conversation), {}, {
1204
1013
  url: this.getConvoUrl(conversation)
1205
1014
  });
1206
-
1207
1015
  activity.parent = {
1208
1016
  id: parentActivity.id,
1209
1017
  type: 'cardAction'
@@ -1218,7 +1026,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1218
1026
  return _this16.submit(a);
1219
1027
  });
1220
1028
  },
1221
-
1222
1029
  /**
1223
1030
  * Posts a message to a conversation
1224
1031
  * @param {Object} conversation
@@ -1231,17 +1038,14 @@ var Conversation = _webexCore.WebexPlugin.extend({
1231
1038
  */
1232
1039
  post: function post(conversation, message, activity) {
1233
1040
  var _this17 = this;
1234
-
1235
1041
  var convoWithUrl = _objectSpread(_objectSpread({}, conversation), {}, {
1236
1042
  url: this.getConvoUrl(conversation)
1237
1043
  });
1238
-
1239
1044
  if ((0, _isString2.default)(message)) {
1240
1045
  message = {
1241
1046
  displayName: message
1242
1047
  };
1243
1048
  }
1244
-
1245
1049
  return this.prepare(activity, {
1246
1050
  verb: 'post',
1247
1051
  target: this.prepareConversation(convoWithUrl),
@@ -1259,7 +1063,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1259
1063
  },
1260
1064
  prepare: function prepare(activity, params) {
1261
1065
  var _this18 = this;
1262
-
1263
1066
  params = params || {};
1264
1067
  activity = activity || {};
1265
1068
  return _promise.default.resolve(activity.prepare ? activity.prepare(params) : activity).then(function (act) {
@@ -1269,35 +1072,32 @@ var Conversation = _webexCore.WebexPlugin.extend({
1269
1072
  objectType: 'activity',
1270
1073
  clientTempId: _uuid.default.v4(),
1271
1074
  actor: _this18.webex.internal.device.userId
1272
- }); // Workaround because parent is a reserved props in Ampersand
1075
+ });
1273
1076
 
1077
+ // Workaround because parent is a reserved props in Ampersand
1274
1078
  if (activity.parentActivityId && activity.activityType || activity.parent && activity.parent.id && activity.parent.type) {
1275
1079
  act.parent = {
1276
1080
  id: activity.parentActivityId || activity.parent.id,
1277
1081
  type: activity.activityType || activity.parent.type
1278
1082
  };
1279
1083
  }
1280
-
1281
1084
  if ((0, _isString2.default)(act.actor)) {
1282
1085
  act.actor = {
1283
1086
  objectType: 'person',
1284
1087
  id: act.actor
1285
1088
  };
1286
1089
  }
1287
-
1288
1090
  ['actor', 'object'].forEach(function (key) {
1289
1091
  if (params[key]) {
1290
1092
  act[key] = act[key] || {};
1291
1093
  (0, _defaults2.default)(act[key], params[key]);
1292
1094
  }
1293
1095
  });
1294
-
1295
1096
  if (params.target) {
1296
1097
  (0, _merge2.default)(act, {
1297
1098
  target: (0, _pick2.default)(params.target, 'id', 'url', 'objectType', 'kmsResourceObjectUrl', 'defaultActivityEncryptionKeyUrl')
1298
1099
  });
1299
1100
  }
1300
-
1301
1101
  ['object', 'target'].forEach(function (key) {
1302
1102
  if (act[key] && act[key].url && !act[key].id) {
1303
1103
  act[key].id = act[key].url.split('/').pop();
@@ -1310,15 +1110,12 @@ var Conversation = _webexCore.WebexPlugin.extend({
1310
1110
  throw new Error("`act.".concat(key, ".objectType` must be defined"));
1311
1111
  }
1312
1112
  });
1313
-
1314
1113
  if (act.object && act.object.content && !act.object.displayName) {
1315
1114
  return _promise.default.reject(new Error('Cannot submit activity object with `content` but no `displayName`'));
1316
1115
  }
1317
-
1318
1116
  return act;
1319
1117
  });
1320
1118
  },
1321
-
1322
1119
  /**
1323
1120
  * Get a subset of threads for a user.
1324
1121
  * @param {Object} options
@@ -1326,27 +1123,22 @@ var Conversation = _webexCore.WebexPlugin.extend({
1326
1123
  */
1327
1124
  listThreads: function listThreads(options) {
1328
1125
  var _this19 = this;
1329
-
1330
1126
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
1331
1127
  return _regenerator.default.wrap(function _callee6$(_context6) {
1332
- while (1) {
1333
- switch (_context6.prev = _context6.next) {
1334
- case 0:
1335
- return _context6.abrupt("return", _this19._list({
1336
- service: 'conversation',
1337
- resource: 'threads',
1338
- qs: (0, _omit2.default)(options, 'showAllTypes')
1339
- }));
1340
-
1341
- case 1:
1342
- case "end":
1343
- return _context6.stop();
1344
- }
1128
+ while (1) switch (_context6.prev = _context6.next) {
1129
+ case 0:
1130
+ return _context6.abrupt("return", _this19._list({
1131
+ service: 'conversation',
1132
+ resource: 'threads',
1133
+ qs: (0, _omit2.default)(options, 'showAllTypes')
1134
+ }));
1135
+ case 1:
1136
+ case "end":
1137
+ return _context6.stop();
1345
1138
  }
1346
1139
  }, _callee6);
1347
1140
  }))();
1348
1141
  },
1349
-
1350
1142
  /**
1351
1143
  * Handles incoming conversation.activity mercury messages
1352
1144
  * @param {Event} event
@@ -1357,7 +1149,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1357
1149
  return event;
1358
1150
  });
1359
1151
  },
1360
-
1361
1152
  /**
1362
1153
  * Handles incoming conversation.inmeetingchat.activity mercury messages
1363
1154
  * @param {Event} event
@@ -1368,7 +1159,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1368
1159
  return event;
1369
1160
  });
1370
1161
  },
1371
-
1372
1162
  /**
1373
1163
  * Removes all mute-related tags
1374
1164
  * @param {Conversation~ConversationObject} conversation
@@ -1380,7 +1170,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1380
1170
  tags: ['MENTION_NOTIFICATIONS_OFF', 'MENTION_NOTIFICATIONS_ON', 'MESSAGE_NOTIFICATIONS_OFF', 'MESSAGE_NOTIFICATIONS_ON']
1381
1171
  }, activity);
1382
1172
  },
1383
-
1384
1173
  /**
1385
1174
  * Creates a ShareActivty for the specified conversation
1386
1175
  * @param {Object} conversation
@@ -1395,7 +1184,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1395
1184
  // back properly oriented from the server since the clientTempId is missing
1396
1185
  return _shareActivity.default.create(conversation, activity, this.webex);
1397
1186
  },
1398
-
1399
1187
  /**
1400
1188
  * Assigns an avatar to a room
1401
1189
  * @param {Object} conversation
@@ -1404,22 +1192,17 @@ var Conversation = _webexCore.WebexPlugin.extend({
1404
1192
  */
1405
1193
  assign: function assign(conversation, avatar) {
1406
1194
  var _this20 = this;
1407
-
1408
1195
  var uploadOptions = {
1409
1196
  role: 'spaceAvatar'
1410
1197
  };
1411
-
1412
1198
  if ((avatar.size || avatar.length) > 1024 * 1024) {
1413
1199
  return _promise.default.reject(new Error('Room avatars must be less than 1MB'));
1414
1200
  }
1415
-
1416
1201
  var convoWithUrl = _objectSpread(_objectSpread({}, conversation), {}, {
1417
1202
  url: this.getConvoUrl(conversation)
1418
1203
  });
1419
-
1420
1204
  return _promise.default.resolve().then(function () {
1421
1205
  var activity = _shareActivity.default.create(conversation, null, _this20.webex);
1422
-
1423
1206
  activity.enableThumbnails = false;
1424
1207
  activity.add(avatar, uploadOptions);
1425
1208
  return _this20.prepare(activity, {
@@ -1432,7 +1215,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1432
1215
  return _this20.submit(a);
1433
1216
  });
1434
1217
  },
1435
-
1436
1218
  /**
1437
1219
  * Get url from convo object. If there isn't one, get it from the cache
1438
1220
  *
@@ -1445,11 +1227,10 @@ var Conversation = _webexCore.WebexPlugin.extend({
1445
1227
  */
1446
1228
  getConvoUrl: function getConvoUrl(_ref4) {
1447
1229
  var id = _ref4.id,
1448
- url = _ref4.url,
1449
- cluster = _ref4.cluster,
1450
- conversations = _ref4.conversations,
1451
- generalConversationUuid = _ref4.generalConversationUuid;
1452
-
1230
+ url = _ref4.url,
1231
+ cluster = _ref4.cluster,
1232
+ conversations = _ref4.conversations,
1233
+ generalConversationUuid = _ref4.generalConversationUuid;
1453
1234
  if (generalConversationUuid) {
1454
1235
  // This is a Team
1455
1236
  // Because Convo doesn't have an endpoint for the team URL
@@ -1459,11 +1240,9 @@ var Conversation = _webexCore.WebexPlugin.extend({
1459
1240
  });
1460
1241
  return generalConvo.url;
1461
1242
  }
1462
-
1463
1243
  if (url) {
1464
1244
  return url;
1465
1245
  }
1466
-
1467
1246
  if (id) {
1468
1247
  if (cluster) {
1469
1248
  return this.getUrlFromClusterId({
@@ -1471,20 +1250,15 @@ var Conversation = _webexCore.WebexPlugin.extend({
1471
1250
  id: id
1472
1251
  });
1473
1252
  }
1474
-
1475
1253
  this.logger.warn('You should be using the `url` instead of the `id` property');
1476
1254
  var relatedUrl = idToUrl.get(id);
1477
-
1478
1255
  if (!relatedUrl) {
1479
1256
  throw Error('Could not find the `url` from the given `id`');
1480
1257
  }
1481
-
1482
1258
  return relatedUrl;
1483
1259
  }
1484
-
1485
1260
  throw Error('The space needs a `url` property');
1486
1261
  },
1487
-
1488
1262
  /**
1489
1263
  * Sets the typing status of the current user in a conversation
1490
1264
  *
@@ -1501,15 +1275,12 @@ var Conversation = _webexCore.WebexPlugin.extend({
1501
1275
  return _promise.default.reject(new Error('conversation: could not identify conversation'));
1502
1276
  }
1503
1277
  }
1504
-
1505
1278
  var eventType;
1506
-
1507
1279
  if (options.typing) {
1508
1280
  eventType = 'status.start_typing';
1509
1281
  } else {
1510
1282
  eventType = 'status.stop_typing';
1511
1283
  }
1512
-
1513
1284
  var url = this.getConvoUrl(conversation);
1514
1285
  var resource = 'status/typing';
1515
1286
  var params = {
@@ -1522,7 +1293,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1522
1293
  };
1523
1294
  return this.request(params);
1524
1295
  },
1525
-
1526
1296
  /**
1527
1297
  * Shares files to the specified conversation
1528
1298
  * @param {Object} conversation
@@ -1531,7 +1301,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1531
1301
  */
1532
1302
  share: function share(conversation, activity) {
1533
1303
  var _this21 = this;
1534
-
1535
1304
  if ((0, _isArray2.default)(activity)) {
1536
1305
  activity = {
1537
1306
  object: {
@@ -1539,22 +1308,18 @@ var Conversation = _webexCore.WebexPlugin.extend({
1539
1308
  }
1540
1309
  };
1541
1310
  }
1542
-
1543
1311
  var convoWithUrl = _objectSpread(_objectSpread({}, conversation), {}, {
1544
1312
  url: this.getConvoUrl(conversation)
1545
1313
  });
1546
-
1547
1314
  if (!(activity instanceof _shareActivity.default)) {
1548
1315
  activity = _shareActivity.default.create(convoWithUrl, activity, this.webex);
1549
1316
  }
1550
-
1551
1317
  return this.prepare(activity, {
1552
1318
  target: this.prepareConversation(convoWithUrl)
1553
1319
  }).then(function (a) {
1554
1320
  return _this21.submit(a);
1555
1321
  });
1556
1322
  },
1557
-
1558
1323
  /**
1559
1324
  * Submits an activity to the conversation service
1560
1325
  * @param {Object} activity
@@ -1563,7 +1328,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1563
1328
  */
1564
1329
  submit: function submit(activity, endpoint) {
1565
1330
  var _this22 = this;
1566
-
1567
1331
  var url = endpoint || this.getConvoUrl(activity.target);
1568
1332
  var resource = activity.verb === 'share' ? 'content' : 'activities';
1569
1333
  var params = {
@@ -1574,7 +1338,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1574
1338
  },
1575
1339
  url: "".concat(url, "/").concat(resource)
1576
1340
  };
1577
-
1578
1341
  if (activity.verb === 'share') {
1579
1342
  (0, _assign.default)(params.qs, {
1580
1343
  transcode: true,
@@ -1587,11 +1350,8 @@ var Conversation = _webexCore.WebexPlugin.extend({
1587
1350
  * @returns {Object|null}
1588
1351
  */
1589
1352
  // eslint-disable-next-line consistent-return
1590
-
1591
-
1592
1353
  var customActivityCopy = function customActivityCopy(value) {
1593
1354
  var files = params.body.object.files;
1594
-
1595
1355
  if (files && value && files.items.length > 0 && value.constructor === files.items[0].scr.constructor) {
1596
1356
  var copySrc = (0, _cloneDeep2.default)(value);
1597
1357
  copySrc.toJWE = value.toJWE;
@@ -1599,9 +1359,9 @@ var Conversation = _webexCore.WebexPlugin.extend({
1599
1359
  return copySrc;
1600
1360
  }
1601
1361
  };
1362
+ var cloneActivity = (0, _cloneDeepWith2.default)(params, customActivityCopy);
1602
1363
 
1603
- var cloneActivity = (0, _cloneDeepWith2.default)(params, customActivityCopy); // triggers user-activity to reset logout timer
1604
-
1364
+ // triggers user-activity to reset logout timer
1605
1365
  this.webex.trigger('user-activity');
1606
1366
  return this.request(params).then(function (res) {
1607
1367
  return res.body;
@@ -1609,7 +1369,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1609
1369
  // handle when key need to rotate
1610
1370
  if (error.body && error.body.errorCode === _constants.KEY_ROTATION_REQUIRED) {
1611
1371
  cloneActivity.body.target.defaultActivityEncryptionKeyUrl = null;
1612
-
1613
1372
  _this22.request(cloneActivity);
1614
1373
  } else if (error.body && (error.body.errorCode === _constants.KEY_ALREADY_ROTATED || error.body.errorCode === _constants.ENCRYPTION_KEY_URL_MISMATCH)) {
1615
1374
  // handle when key need to update
@@ -1619,7 +1378,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1619
1378
  resource: "conversations/".concat(params.body.target.id)
1620
1379
  }).then(function (res) {
1621
1380
  cloneActivity.body.target.defaultActivityEncryptionKeyUrl = res.body.defaultActivityEncryptionkeyUrl;
1622
-
1623
1381
  _this22.request(cloneActivity);
1624
1382
  });
1625
1383
  } else {
@@ -1627,7 +1385,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1627
1385
  }
1628
1386
  });
1629
1387
  },
1630
-
1631
1388
  /**
1632
1389
  * Remove the avatar from a room
1633
1390
  * @param {Conversation~ConversationObject} conversation
@@ -1636,11 +1393,9 @@ var Conversation = _webexCore.WebexPlugin.extend({
1636
1393
  */
1637
1394
  unassign: function unassign(conversation, activity) {
1638
1395
  var _this23 = this;
1639
-
1640
1396
  var convoWithUrl = _objectSpread(_objectSpread({}, conversation), {}, {
1641
1397
  url: this.getConvoUrl(conversation)
1642
1398
  });
1643
-
1644
1399
  return this.prepare(activity, {
1645
1400
  verb: 'unassign',
1646
1401
  target: this.prepareConversation(convoWithUrl),
@@ -1654,7 +1409,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1654
1409
  return _this23.submit(a);
1655
1410
  });
1656
1411
  },
1657
-
1658
1412
  /**
1659
1413
  * Mutes the mentions of a conversation
1660
1414
  * @param {Conversation~ConversationObject} conversation
@@ -1666,7 +1420,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1666
1420
  tags: ['MENTION_NOTIFICATIONS_ON']
1667
1421
  }, activity);
1668
1422
  },
1669
-
1670
1423
  /**
1671
1424
  * Mutes the messages of a conversation
1672
1425
  * @param {Conversation~ConversationObject} conversation
@@ -1678,7 +1431,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1678
1431
  tags: ['MESSAGE_NOTIFICATIONS_ON']
1679
1432
  }, activity);
1680
1433
  },
1681
-
1682
1434
  /**
1683
1435
  * Stops ignoring conversation
1684
1436
  * @param {Conversation~ConversationObject} conversation
@@ -1690,7 +1442,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1690
1442
  tags: ['IGNORED']
1691
1443
  }, activity);
1692
1444
  },
1693
-
1694
1445
  /**
1695
1446
  * Update an existing activity
1696
1447
  * @param {Object} conversation
@@ -1700,15 +1451,12 @@ var Conversation = _webexCore.WebexPlugin.extend({
1700
1451
  */
1701
1452
  update: function update(conversation, object, activity) {
1702
1453
  var _this24 = this;
1703
-
1704
1454
  if (!(0, _isObject2.default)(object)) {
1705
1455
  return _promise.default.reject(new Error('`object` must be an object'));
1706
1456
  }
1707
-
1708
1457
  var convoWithUrl = _objectSpread(_objectSpread({}, conversation), {}, {
1709
1458
  url: this.getConvoUrl(conversation)
1710
1459
  });
1711
-
1712
1460
  return this.prepare(activity, {
1713
1461
  verb: 'update',
1714
1462
  target: this.prepareConversation(convoWithUrl),
@@ -1717,7 +1465,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1717
1465
  return _this24.submit(a);
1718
1466
  });
1719
1467
  },
1720
-
1721
1468
  /**
1722
1469
  * Sets a new key for the conversation
1723
1470
  * @param {Object} conversation
@@ -1729,11 +1476,9 @@ var Conversation = _webexCore.WebexPlugin.extend({
1729
1476
  */
1730
1477
  updateKey: function updateKey(conversation, key, activity) {
1731
1478
  var _this25 = this;
1732
-
1733
1479
  var convoWithUrl = _objectSpread(_objectSpread({}, conversation), {}, {
1734
1480
  url: this.getConvoUrl(conversation)
1735
1481
  });
1736
-
1737
1482
  return this.get(convoWithUrl, {
1738
1483
  activitiesLimit: 0,
1739
1484
  includeParticipants: true
@@ -1741,7 +1486,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1741
1486
  return _this25._updateKey(c, key, activity);
1742
1487
  });
1743
1488
  },
1744
-
1745
1489
  /**
1746
1490
  * Sets a new key for the conversation
1747
1491
  * @param {Object} conversation
@@ -1754,11 +1498,9 @@ var Conversation = _webexCore.WebexPlugin.extend({
1754
1498
  */
1755
1499
  _updateKey: function _updateKey(conversation, key, activity) {
1756
1500
  var _this26 = this;
1757
-
1758
1501
  var convoWithUrl = _objectSpread(_objectSpread({}, conversation), {}, {
1759
1502
  url: this.getConvoUrl(conversation)
1760
1503
  });
1761
-
1762
1504
  return _promise.default.resolve(key || this.webex.internal.encryption.kms.createUnboundKeys({
1763
1505
  count: 1
1764
1506
  })).then(function (keys) {
@@ -1770,10 +1512,11 @@ var Conversation = _webexCore.WebexPlugin.extend({
1770
1512
  defaultActivityEncryptionKeyUrl: k.uri,
1771
1513
  objectType: 'conversation'
1772
1514
  }
1773
- }; // Reminder: the kmsResourceObjectUrl is only usable if there is
1515
+ };
1516
+
1517
+ // Reminder: the kmsResourceObjectUrl is only usable if there is
1774
1518
  // defaultActivityEncryptionKeyUrl.
1775
1519
  // Valid defaultActivityEncryptionKeyUrl start with 'kms:'
1776
-
1777
1520
  if (convoWithUrl.kmsResourceObjectUrl && convoWithUrl.kmsResourceObjectUrl.startsWith('kms:')) {
1778
1521
  params.kmsMessage = {
1779
1522
  method: 'update',
@@ -1788,13 +1531,11 @@ var Conversation = _webexCore.WebexPlugin.extend({
1788
1531
  keyUris: [k.uri]
1789
1532
  };
1790
1533
  }
1791
-
1792
1534
  return _this26.prepare(activity, params).then(function (a) {
1793
1535
  return _this26.submit(a);
1794
1536
  });
1795
1537
  });
1796
1538
  },
1797
-
1798
1539
  /**
1799
1540
  * @param {Object} payload
1800
1541
  * @param {Object} options
@@ -1815,7 +1556,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1815
1556
  return res.body;
1816
1557
  });
1817
1558
  },
1818
-
1819
1559
  /**
1820
1560
  * @param {Object} params
1821
1561
  * @param {Object} options
@@ -1825,7 +1565,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1825
1565
  _createGrouped: function _createGrouped(params, options) {
1826
1566
  return this._create(this._prepareConversationForCreation(params), options);
1827
1567
  },
1828
-
1829
1568
  /**
1830
1569
  * @param {Object} params
1831
1570
  * @param {Object} options
@@ -1834,11 +1573,9 @@ var Conversation = _webexCore.WebexPlugin.extend({
1834
1573
  */
1835
1574
  _createOneOnOne: function _createOneOnOne(params) {
1836
1575
  var payload = this._prepareConversationForCreation(params);
1837
-
1838
1576
  payload.tags = ['ONE_ON_ONE'];
1839
1577
  return this._create(payload);
1840
1578
  },
1841
-
1842
1579
  /**
1843
1580
  * Get the current conversation url.
1844
1581
  *
@@ -1846,26 +1583,24 @@ var Conversation = _webexCore.WebexPlugin.extend({
1846
1583
  */
1847
1584
  getConversationUrl: function getConversationUrl() {
1848
1585
  var _this27 = this;
1849
-
1850
1586
  this.logger.info('conversation: getting the conversation service url');
1851
- var convoUrl = this.webex.internal.services.get('conversation'); // Validate if the conversation url exists in the services plugin and
1852
- // resolve with its value.
1587
+ var convoUrl = this.webex.internal.services.get('conversation');
1853
1588
 
1589
+ // Validate if the conversation url exists in the services plugin and
1590
+ // resolve with its value.
1854
1591
  if (convoUrl) {
1855
1592
  return _promise.default.resolve(convoUrl);
1856
- } // Wait for the postauth catalog to update and then try to retrieve the
1857
- // conversation service url again.
1858
-
1593
+ }
1859
1594
 
1595
+ // Wait for the postauth catalog to update and then try to retrieve the
1596
+ // conversation service url again.
1860
1597
  return this.webex.internal.waitForCatalog('postauth').then(function () {
1861
1598
  return _this27.webex.internal.services.get('conversation');
1862
1599
  }).catch(function (error) {
1863
1600
  _this27.logger.warn('conversation: unable to get conversation url', error.message);
1864
-
1865
1601
  return _promise.default.reject(error);
1866
1602
  });
1867
1603
  },
1868
-
1869
1604
  /**
1870
1605
  * @param {Object} conversation
1871
1606
  * @private
@@ -1873,7 +1608,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
1873
1608
  */
1874
1609
  _inferConversationUrl: function _inferConversationUrl(conversation) {
1875
1610
  var _this28 = this;
1876
-
1877
1611
  if (conversation.id) {
1878
1612
  return this.webex.internal.feature.getFeature('developer', 'web-high-availability').then(function (haMessagingEnabled) {
1879
1613
  if (haMessagingEnabled) {
@@ -1884,27 +1618,21 @@ var Conversation = _webexCore.WebexPlugin.extend({
1884
1618
  return conversation;
1885
1619
  });
1886
1620
  }
1887
-
1888
1621
  if (!conversation.url) {
1889
1622
  return _this28.getConversationUrl().then(function (url) {
1890
1623
  conversation.url = "".concat(url, "/conversations/").concat(conversation.id);
1891
1624
  /* istanbul ignore else */
1892
-
1893
1625
  if (process.env.NODE_ENV !== 'production') {
1894
1626
  _this28.logger.warn('conversation: inferred conversation url from conversation id; please pass whole conversation objects to Conversation methods');
1895
1627
  }
1896
-
1897
1628
  return conversation;
1898
1629
  });
1899
1630
  }
1900
-
1901
1631
  return _promise.default.resolve(conversation);
1902
1632
  });
1903
1633
  }
1904
-
1905
1634
  return _promise.default.resolve(conversation);
1906
1635
  },
1907
-
1908
1636
  /**
1909
1637
  * @param {Object} options
1910
1638
  * @param {String} options.conversationUrl URL to the conversation
@@ -1924,14 +1652,12 @@ var Conversation = _webexCore.WebexPlugin.extend({
1924
1652
  url: "".concat(url, "/").concat(resource)
1925
1653
  });
1926
1654
  },
1927
-
1928
1655
  /**
1929
1656
  * common interface for facade of generator functions
1930
1657
  * @typedef {object} IGeneratorResponse
1931
1658
  * @param {boolean} done whether there is more to fetch
1932
1659
  * @param {any} value the value yielded or returned by generator
1933
1660
  */
1934
-
1935
1661
  /**
1936
1662
  * @param {object} options
1937
1663
  * @param {string} options.conversationId
@@ -1952,28 +1678,23 @@ var Conversation = _webexCore.WebexPlugin.extend({
1952
1678
  */
1953
1679
  listActivitiesThreadOrdered: function listActivitiesThreadOrdered(options) {
1954
1680
  var _this29 = this;
1955
-
1956
1681
  var conversationUrl = options.conversationUrl,
1957
- conversationId = options.conversationId;
1958
-
1682
+ conversationId = options.conversationId;
1959
1683
  if (!conversationUrl && !conversationId) {
1960
1684
  throw new Error('must provide a conversation URL or conversation ID');
1961
1685
  }
1962
-
1963
1686
  var url = this.getConvoUrl({
1964
1687
  url: conversationUrl,
1965
1688
  id: conversationId
1966
1689
  });
1967
-
1968
1690
  var baseOptions = _objectSpread(_objectSpread({}, (0, _omit2.default)(options, ['conversationUrl', 'conversationId'])), {}, {
1969
1691
  url: url
1970
1692
  });
1971
-
1972
1693
  var olderOptions = _objectSpread(_objectSpread({}, baseOptions), {}, {
1973
1694
  queryType: _activities.OLDER
1974
1695
  });
1975
-
1976
1696
  var threadOrderer = this._listActivitiesThreadOrdered(baseOptions);
1697
+
1977
1698
  /**
1978
1699
  * gets queried activity and surrounding activities
1979
1700
  * calling this function creates a new generator instance, losing the previous instance's internal state
@@ -1981,157 +1702,127 @@ var Conversation = _webexCore.WebexPlugin.extend({
1981
1702
  * @param {object} searchObject activity object from convo
1982
1703
  * @returns {IGeneratorResponse}
1983
1704
  */
1984
-
1985
-
1986
1705
  var jumpToActivity = /*#__PURE__*/function () {
1987
1706
  var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(searchObject) {
1988
1707
  var newUrl, searchOptions, _yield$threadOrderer$, searchResults;
1989
-
1990
1708
  return _regenerator.default.wrap(function _callee7$(_context7) {
1991
- while (1) {
1992
- switch (_context7.prev = _context7.next) {
1993
- case 0:
1994
- if (searchObject) {
1995
- _context7.next = 2;
1996
- break;
1997
- }
1998
-
1999
- throw new Error('Search must be an activity object from conversation service');
2000
-
2001
- case 2:
2002
- newUrl = searchObject.target && searchObject.target.url;
2003
-
2004
- if (newUrl) {
2005
- _context7.next = 5;
2006
- break;
2007
- }
2008
-
2009
- throw new Error('Search object must have a target url!');
2010
-
2011
- case 5:
2012
- searchOptions = _objectSpread(_objectSpread({}, baseOptions), {}, {
2013
- url: newUrl,
2014
- queryType: _activities.MID,
2015
- search: searchObject
2016
- });
2017
- threadOrderer = _this29._listActivitiesThreadOrdered(searchOptions);
2018
- _context7.next = 9;
2019
- return threadOrderer.next(searchOptions);
2020
-
2021
- case 9:
2022
- _yield$threadOrderer$ = _context7.sent;
2023
- searchResults = _yield$threadOrderer$.value;
2024
- return _context7.abrupt("return", {
2025
- done: true,
2026
- value: searchResults
2027
- });
2028
-
2029
- case 12:
2030
- case "end":
2031
- return _context7.stop();
2032
- }
1709
+ while (1) switch (_context7.prev = _context7.next) {
1710
+ case 0:
1711
+ if (searchObject) {
1712
+ _context7.next = 2;
1713
+ break;
1714
+ }
1715
+ throw new Error('Search must be an activity object from conversation service');
1716
+ case 2:
1717
+ newUrl = searchObject.target && searchObject.target.url;
1718
+ if (newUrl) {
1719
+ _context7.next = 5;
1720
+ break;
1721
+ }
1722
+ throw new Error('Search object must have a target url!');
1723
+ case 5:
1724
+ searchOptions = _objectSpread(_objectSpread({}, baseOptions), {}, {
1725
+ url: newUrl,
1726
+ queryType: _activities.MID,
1727
+ search: searchObject
1728
+ });
1729
+ threadOrderer = _this29._listActivitiesThreadOrdered(searchOptions);
1730
+ _context7.next = 9;
1731
+ return threadOrderer.next(searchOptions);
1732
+ case 9:
1733
+ _yield$threadOrderer$ = _context7.sent;
1734
+ searchResults = _yield$threadOrderer$.value;
1735
+ return _context7.abrupt("return", {
1736
+ done: true,
1737
+ value: searchResults
1738
+ });
1739
+ case 12:
1740
+ case "end":
1741
+ return _context7.stop();
2033
1742
  }
2034
1743
  }, _callee7);
2035
1744
  }));
2036
-
2037
1745
  return function jumpToActivity(_x) {
2038
1746
  return _ref5.apply(this, arguments);
2039
1747
  };
2040
1748
  }();
1749
+
2041
1750
  /**
2042
1751
  * gets older activities than oldest fetched
2043
1752
  * @returns {IGeneratorResponse}
2044
1753
  */
2045
-
2046
-
2047
1754
  var getOlder = /*#__PURE__*/function () {
2048
1755
  var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
2049
1756
  var _yield$threadOrderer$2, _yield$threadOrderer$3, value, oldestInBatch, moreActivitiesExist;
2050
-
2051
1757
  return _regenerator.default.wrap(function _callee8$(_context8) {
2052
- while (1) {
2053
- switch (_context8.prev = _context8.next) {
2054
- case 0:
2055
- _context8.next = 2;
2056
- return threadOrderer.next(olderOptions);
2057
-
2058
- case 2:
2059
- _yield$threadOrderer$2 = _context8.sent;
2060
- _yield$threadOrderer$3 = _yield$threadOrderer$2.value;
2061
- value = _yield$threadOrderer$3 === void 0 ? [] : _yield$threadOrderer$3;
2062
- oldestInBatch = value[0] && value[0].activity;
2063
- moreActivitiesExist = oldestInBatch && (0, _activities.getActivityType)(oldestInBatch) !== _activities.ACTIVITY_TYPES.CREATE;
2064
- return _context8.abrupt("return", {
2065
- done: !moreActivitiesExist,
2066
- value: value
2067
- });
2068
-
2069
- case 8:
2070
- case "end":
2071
- return _context8.stop();
2072
- }
1758
+ while (1) switch (_context8.prev = _context8.next) {
1759
+ case 0:
1760
+ _context8.next = 2;
1761
+ return threadOrderer.next(olderOptions);
1762
+ case 2:
1763
+ _yield$threadOrderer$2 = _context8.sent;
1764
+ _yield$threadOrderer$3 = _yield$threadOrderer$2.value;
1765
+ value = _yield$threadOrderer$3 === void 0 ? [] : _yield$threadOrderer$3;
1766
+ oldestInBatch = value[0] && value[0].activity;
1767
+ moreActivitiesExist = oldestInBatch && (0, _activities.getActivityType)(oldestInBatch) !== _activities.ACTIVITY_TYPES.CREATE;
1768
+ return _context8.abrupt("return", {
1769
+ done: !moreActivitiesExist,
1770
+ value: value
1771
+ });
1772
+ case 8:
1773
+ case "end":
1774
+ return _context8.stop();
2073
1775
  }
2074
1776
  }, _callee8);
2075
1777
  }));
2076
-
2077
1778
  return function getOlder() {
2078
1779
  return _ref6.apply(this, arguments);
2079
1780
  };
2080
1781
  }();
1782
+
2081
1783
  /**
2082
1784
  * gets newer activities than newest fetched
2083
1785
  * @returns {IGeneratorResponse}
2084
1786
  */
2085
-
2086
-
2087
1787
  var getNewer = /*#__PURE__*/function () {
2088
1788
  var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
2089
1789
  var newerOptions, _yield$threadOrderer$4, value;
2090
-
2091
1790
  return _regenerator.default.wrap(function _callee9$(_context9) {
2092
- while (1) {
2093
- switch (_context9.prev = _context9.next) {
2094
- case 0:
2095
- newerOptions = _objectSpread(_objectSpread({}, baseOptions), {}, {
2096
- queryType: _activities.NEWER
2097
- });
2098
- _context9.next = 3;
2099
- return threadOrderer.next(newerOptions);
2100
-
2101
- case 3:
2102
- _yield$threadOrderer$4 = _context9.sent;
2103
- value = _yield$threadOrderer$4.value;
2104
- return _context9.abrupt("return", {
2105
- done: !value.length,
2106
- value: value
2107
- });
2108
-
2109
- case 6:
2110
- case "end":
2111
- return _context9.stop();
2112
- }
1791
+ while (1) switch (_context9.prev = _context9.next) {
1792
+ case 0:
1793
+ newerOptions = _objectSpread(_objectSpread({}, baseOptions), {}, {
1794
+ queryType: _activities.NEWER
1795
+ });
1796
+ _context9.next = 3;
1797
+ return threadOrderer.next(newerOptions);
1798
+ case 3:
1799
+ _yield$threadOrderer$4 = _context9.sent;
1800
+ value = _yield$threadOrderer$4.value;
1801
+ return _context9.abrupt("return", {
1802
+ done: !value.length,
1803
+ value: value
1804
+ });
1805
+ case 6:
1806
+ case "end":
1807
+ return _context9.stop();
2113
1808
  }
2114
1809
  }, _callee9);
2115
1810
  }));
2116
-
2117
1811
  return function getNewer() {
2118
1812
  return _ref7.apply(this, arguments);
2119
1813
  };
2120
1814
  }();
2121
-
2122
1815
  return {
2123
1816
  jumpToActivity: jumpToActivity,
2124
1817
  getNewer: getNewer,
2125
1818
  getOlder: getOlder
2126
1819
  };
2127
1820
  },
2128
-
2129
1821
  /**
2130
1822
  * Represents reactions to messages
2131
1823
  * @typedef {object} Reaction
2132
1824
  * @property {object} activity reaction2summary server activity object
2133
1825
  */
2134
-
2135
1826
  /**
2136
1827
  * Represents a root (parent, with or without children) activity, along with any replies and reactions
2137
1828
  * @typedef {object} Activity
@@ -2139,7 +1830,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
2139
1830
  * @property {Reaction} reactions
2140
1831
  * @property {Reaction} reactionSelf
2141
1832
  */
2142
-
2143
1833
  /**
2144
1834
  * @generator
2145
1835
  * @method
@@ -2158,474 +1848,394 @@ var Conversation = _webexCore.WebexPlugin.extend({
2158
1848
  */
2159
1849
  _listActivitiesThreadOrdered: function _listActivitiesThreadOrdered() {
2160
1850
  var _this = this;
2161
-
2162
1851
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2163
1852
  return (0, _wrapAsyncGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
2164
1853
  var _options$minActivitie, minActivities, _options$queryType, queryType, convoUrl, _options$search, search, includeChildren, _bookendManager, setBookends, getNewestAct, getOldestAct, defaultBatchSize, batchSize, _activityManager, getActivityHandlerByKey, getActivityByTypeAndParentId, query, _loop, _ret;
2165
-
2166
1854
  return _regenerator.default.wrap(function _callee10$(_context12) {
2167
- while (1) {
2168
- switch (_context12.prev = _context12.next) {
2169
- case 0:
2170
- // ***********************************************
2171
- // INSTANCE STATE VARIABLES
2172
- // variables that will be used for the life of the generator
2173
- // ***********************************************
2174
- _options$minActivitie = options.minActivities, minActivities = _options$minActivitie === void 0 ? _activityThreadOrdering.defaultMinDisplayableActivities : _options$minActivitie, _options$queryType = options.queryType, queryType = _options$queryType === void 0 ? _activities.INITIAL : _options$queryType; // must fetch initially before getting newer activities!
2175
-
2176
- if (queryType === _activities.NEWER) {
2177
- queryType = _activities.INITIAL;
2178
- }
2179
-
2180
- convoUrl = options.url, _options$search = options.search, search = _options$search === void 0 ? {} : _options$search, includeChildren = options.includeChildren; // manage oldest, newest activities (ie bookends)
2181
-
2182
- _bookendManager = (0, _activityThreadOrdering.bookendManager)(), setBookends = _bookendManager.setBookends, getNewestAct = _bookendManager.getNewestAct, getOldestAct = _bookendManager.getOldestAct; // default batch should be equal to minActivities when fetching back in time, but halved when fetching newer due to subsequent child fetches filling up the minActivities count
2183
- // reduces server RTs when fetching older activities
2184
-
2185
- defaultBatchSize = queryType === _activities.INITIAL || queryType === _activities.OLDER ? minActivities : Math.max(_activityThreadOrdering.minBatchSize, Math.ceil(minActivities / 2));
2186
- batchSize = defaultBatchSize; // exposes activity states and handlers with simple getters
2187
-
2188
- _activityManager = (0, _activityThreadOrdering.activityManager)(), getActivityHandlerByKey = _activityManager.getActivityHandlerByKey, getActivityByTypeAndParentId = _activityManager.getActivityByTypeAndParentId; // set initial query
2189
-
2190
- query = (0, _activityThreadOrdering.getQuery)(queryType, {
2191
- activityToSearch: search,
2192
- batchSize: batchSize
2193
- });
2194
- /* eslint-disable no-await-in-loop */
2195
-
2196
- /* eslint-disable no-loop-func */
2197
-
2198
- _loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
2199
- var _rootActivityManager, getRootActivityHash, addNewRoot, _noMoreActivitiesMana, getNoMoreActs, checkAndSetNoMoreActs, checkAndSetNoOlderActs, checkAndSetNoNewerActs, getActivityHandlerByType, handleNewActivity, handleNewActivities, handleOlderQuery, handleNewerQuery, handleSearch, getQueryResponseHandler, incrementLoopCounter, _loop2, _ret2, orderedActivities, getRepliesByParentId, orderedRoots, nextOptions, currentOldestPublishedDate, currentNewestPublishedDate;
2200
-
2201
- return _regenerator.default.wrap(function _loop$(_context11) {
2202
- while (1) {
2203
- switch (_context11.prev = _context11.next) {
2204
- case 0:
2205
- // ***********************************************
2206
- // EXECUTION STATE VARIABLES
2207
- // variables that will be used for each "batch" of activities asked for
2208
- // ***********************************************
2209
- // stores all "root" activities (activities that are, or could be, thread parents)
2210
- _rootActivityManager = (0, _activityThreadOrdering.rootActivityManager)(), getRootActivityHash = _rootActivityManager.getRootActivityHash, addNewRoot = _rootActivityManager.addNewRoot; // used to determine if we should continue to fetch older activities
2211
- // must be set per iteration, as querying newer activities is still valid when all end of convo has been reached
2212
-
2213
- _noMoreActivitiesMana = (0, _activityThreadOrdering.noMoreActivitiesManager)(), getNoMoreActs = _noMoreActivitiesMana.getNoMoreActs, checkAndSetNoMoreActs = _noMoreActivitiesMana.checkAndSetNoMoreActs, checkAndSetNoOlderActs = _noMoreActivitiesMana.checkAndSetNoOlderActs, checkAndSetNoNewerActs = _noMoreActivitiesMana.checkAndSetNoNewerActs;
2214
-
2215
- getActivityHandlerByType = function getActivityHandlerByType(type) {
2216
- var _ACTIVITY_TYPES$ROOT$;
2217
-
2218
- return (_ACTIVITY_TYPES$ROOT$ = {}, (0, _defineProperty2.default)(_ACTIVITY_TYPES$ROOT$, _activities.ACTIVITY_TYPES.ROOT, addNewRoot), (0, _defineProperty2.default)(_ACTIVITY_TYPES$ROOT$, _activities.ACTIVITY_TYPES.REPLY, getActivityHandlerByKey(_activities.ACTIVITY_TYPES.REPLY)), (0, _defineProperty2.default)(_ACTIVITY_TYPES$ROOT$, _activities.ACTIVITY_TYPES.EDIT, getActivityHandlerByKey(_activities.ACTIVITY_TYPES.EDIT)), (0, _defineProperty2.default)(_ACTIVITY_TYPES$ROOT$, _activities.ACTIVITY_TYPES.REACTION, getActivityHandlerByKey(_activities.ACTIVITY_TYPES.REACTION)), (0, _defineProperty2.default)(_ACTIVITY_TYPES$ROOT$, _activities.ACTIVITY_TYPES.REACTION_SELF, getActivityHandlerByKey(_activities.ACTIVITY_TYPES.REACTION_SELF)), (0, _defineProperty2.default)(_ACTIVITY_TYPES$ROOT$, _activities.ACTIVITY_TYPES.TOMBSTONE, addNewRoot), (0, _defineProperty2.default)(_ACTIVITY_TYPES$ROOT$, _activities.ACTIVITY_TYPES.CREATE, addNewRoot), _ACTIVITY_TYPES$ROOT$)[type];
2219
- };
2220
-
2221
- handleNewActivity = function handleNewActivity(activity) {
2222
- var actType = (0, _activities.getActivityType)(activity); // ignore deletes
2223
-
2224
- if ((0, _activities.isDeleteActivity)(activity)) {
2225
- return;
2226
- }
2227
-
2228
- var activityHandler = getActivityHandlerByType(actType);
2229
- activityHandler(activity);
2230
- };
2231
-
2232
- handleNewActivities = function handleNewActivities(activities) {
2233
- activities.forEach(function (act) {
2234
- handleNewActivity(act);
2235
- checkAndSetNoOlderActs(act);
2236
- });
2237
- };
2238
-
2239
- handleOlderQuery = function handleOlderQuery(activities) {
2240
- setBookends(activities, _activities.OLDER);
2241
- handleNewActivities(activities);
2242
- };
2243
-
2244
- handleNewerQuery = function handleNewerQuery(activities) {
2245
- checkAndSetNoNewerActs(activities);
2246
-
2247
- if (activities.length) {
2248
- setBookends(activities, _activities.NEWER);
2249
- handleNewActivities(activities);
2250
- }
2251
- };
2252
-
2253
- handleSearch = function handleSearch(activities) {
2254
- setBookends(activities, _activities.MID);
2255
- handleNewActivities(activities);
2256
- };
2257
-
2258
- getQueryResponseHandler = function getQueryResponseHandler(type) {
2259
- var _OLDER$NEWER$MID$INIT;
2260
-
2261
- return (_OLDER$NEWER$MID$INIT = {}, (0, _defineProperty2.default)(_OLDER$NEWER$MID$INIT, _activities.OLDER, handleOlderQuery), (0, _defineProperty2.default)(_OLDER$NEWER$MID$INIT, _activities.NEWER, handleNewerQuery), (0, _defineProperty2.default)(_OLDER$NEWER$MID$INIT, _activities.MID, handleSearch), (0, _defineProperty2.default)(_OLDER$NEWER$MID$INIT, _activities.INITIAL, handleOlderQuery), _OLDER$NEWER$MID$INIT)[type];
2262
- }; // ***********************************************
2263
- // INNER LOOP
2264
- // responsible for fetching and building our maps of activities
2265
- // fetch until minActivities is reached, or no more acts to fetch, or we hit our max fetch count
2266
- // ***********************************************
2267
-
2268
-
2269
- incrementLoopCounter = (0, _activityThreadOrdering.getLoopCounterFailsafe)();
2270
- _loop2 = /*#__PURE__*/_regenerator.default.mark(function _loop2() {
2271
- var allBatchActivitiesConfig, $allBatchActivitiesFetch, $fetchRequests, params, $parentsFetch, _yield$_awaitAsyncGen, _yield$_awaitAsyncGen2, allBatchActivities, _yield$_awaitAsyncGen3, parents, handler, _parents$reply, replyIds, _parents$edit, editIds, _parents$reaction, reactionIds, $reactionFetches, $replyFetches, $editFetches, _iterator4, _step4, activity, actId, childFetchOptions, _yield$_awaitAsyncGen4, _yield$_awaitAsyncGen5, reactions, replies, edits, newReplyReactions, allReactions, rootActivityHash, visibleActivitiesCount, _iterator5, _step5, rootActivity, rootId, repliesByRootId, currentOldestPublishedDate, currentNewestPublishedDate;
2272
-
2273
- return _regenerator.default.wrap(function _loop2$(_context10) {
2274
- while (1) {
2275
- switch (_context10.prev = _context10.next) {
2276
- case 0:
2277
- // count loops and throw if we detect infinite loop
2278
- incrementLoopCounter(); // configure fetch request. Use a smaller limit when fetching newer or mids to account for potential children fetches
2279
-
2280
- allBatchActivitiesConfig = _objectSpread({
2281
- conversationUrl: convoUrl,
2282
- limit: batchSize,
2283
- includeChildren: includeChildren
2284
- }, query); // request activities in batches
2285
-
2286
- $allBatchActivitiesFetch = _this.listActivities(allBatchActivitiesConfig); // contain fetches in array to parallelize fetching as needed
2287
-
2288
- $fetchRequests = [$allBatchActivitiesFetch]; // if query requires recursive fetches for children acts, add the additional fetch
2289
-
2290
- if (queryType === _activities.MID || queryType === _activities.NEWER) {
2291
- params = {
2292
- activityType: null
2293
- };
2294
-
2295
- if (query.sinceDate) {
2296
- params.sinceDate = query.sinceDate;
2297
- }
2298
-
2299
- $parentsFetch = _this.listParentActivityIds(convoUrl, params);
2300
- $fetchRequests.push($parentsFetch);
2301
- } // we dont always need to fetch for parents
2302
-
2303
-
2304
- _context10.next = 7;
2305
- return (0, _awaitAsyncGenerator2.default)(_promise.default.all($fetchRequests));
2306
-
2307
- case 7:
2308
- _yield$_awaitAsyncGen = _context10.sent;
2309
- _yield$_awaitAsyncGen2 = (0, _slicedToArray2.default)(_yield$_awaitAsyncGen, 2);
2310
- allBatchActivities = _yield$_awaitAsyncGen2[0];
2311
- _yield$_awaitAsyncGen3 = _yield$_awaitAsyncGen2[1];
2312
- parents = _yield$_awaitAsyncGen3 === void 0 ? {} : _yield$_awaitAsyncGen3;
2313
- // use query type to decide how to handle response
2314
- handler = getQueryResponseHandler(queryType);
2315
- handler(allBatchActivities);
2316
- /*
2317
- next we must selectively fetch the children of each of the parents to ensure completeness
2318
- do this by checking the hash for each of the above parent IDs
2319
- fetch children when we have a parent whose ID is represented in the parent ID lists
2320
- */
2321
-
2322
- _parents$reply = parents.reply, replyIds = _parents$reply === void 0 ? [] : _parents$reply, _parents$edit = parents.edit, editIds = _parents$edit === void 0 ? [] : _parents$edit, _parents$reaction = parents.reaction, reactionIds = _parents$reaction === void 0 ? [] : _parents$reaction; // if no parent IDs returned, do nothing
2323
-
2324
- if (!(replyIds.length || editIds.length || reactionIds.length)) {
2325
- _context10.next = 35;
2326
- break;
2327
- }
2328
-
2329
- $reactionFetches = [];
2330
- $replyFetches = [];
2331
- $editFetches = [];
2332
- _iterator4 = _createForOfIteratorHelper(allBatchActivities);
2333
-
2334
- try {
2335
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
2336
- activity = _step4.value;
2337
- actId = activity.id;
2338
- childFetchOptions = {
2339
- conversationUrl: convoUrl,
2340
- activityParentId: actId
2341
- };
2342
-
2343
- if (reactionIds.includes(actId)) {
2344
- $reactionFetches.push(_this.getReactionSummaryByParentId(convoUrl, actId, {
2345
- activityType: 'reactionSummary',
2346
- includeChildren: true
2347
- }));
2348
- }
2349
-
2350
- if (replyIds.includes(actId)) {
2351
- childFetchOptions.query = {
2352
- activityType: 'reply'
2353
- };
2354
- $replyFetches.push(_this.listAllChildActivitiesByParentId(childFetchOptions));
2355
- }
2356
-
2357
- if (editIds.includes(actId)) {
2358
- childFetchOptions.query = {
2359
- activityType: 'edit'
2360
- };
2361
- $editFetches.push(_this.listAllChildActivitiesByParentId(childFetchOptions));
2362
- }
2363
- } // parallelize fetch for speeedz
2364
-
2365
- } catch (err) {
2366
- _iterator4.e(err);
2367
- } finally {
2368
- _iterator4.f();
2369
- }
2370
-
2371
- _context10.next = 23;
2372
- return (0, _awaitAsyncGenerator2.default)(_promise.default.all([_promise.default.all($reactionFetches), _promise.default.all($replyFetches), _promise.default.all($editFetches)]));
2373
-
2374
- case 23:
2375
- _yield$_awaitAsyncGen4 = _context10.sent;
2376
- _yield$_awaitAsyncGen5 = (0, _slicedToArray2.default)(_yield$_awaitAsyncGen4, 3);
2377
- reactions = _yield$_awaitAsyncGen5[0];
2378
- replies = _yield$_awaitAsyncGen5[1];
2379
- edits = _yield$_awaitAsyncGen5[2];
2380
- _context10.next = 30;
2381
- return (0, _awaitAsyncGenerator2.default)(_promise.default.all(replies.filter(function (reply) {
2382
- return replyIds.includes(reply.id);
2383
- }).map(function (reply) {
2384
- return _this.getReactionSummaryByParentId(convoUrl, reply.id, {
2385
- activityType: 'reactionSummary',
2386
- includeChildren: true
2387
- });
2388
- })));
2389
-
2390
- case 30:
2391
- newReplyReactions = _context10.sent;
2392
- allReactions = [].concat((0, _toConsumableArray2.default)(reactions), (0, _toConsumableArray2.default)(newReplyReactions)); // stick them into activity hashes
2393
-
2394
- replies.forEach(function (replyArr) {
2395
- return handleNewActivities(replyArr);
2396
- });
2397
- edits.forEach(function (editArr) {
2398
- return handleNewActivities(editArr);
2399
- });
2400
- allReactions.forEach(function (reactionArr) {
2401
- return handleNewActivities(reactionArr);
2402
- });
2403
-
2404
- case 35:
2405
- rootActivityHash = getRootActivityHash();
2406
- visibleActivitiesCount = rootActivityHash.size;
2407
- _iterator5 = _createForOfIteratorHelper(rootActivityHash.values());
2408
-
2409
- try {
2410
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
2411
- rootActivity = _step5.value;
2412
- rootId = rootActivity.id;
2413
- repliesByRootId = getActivityByTypeAndParentId(_activities.ACTIVITY_TYPES.REPLY, rootId);
2414
-
2415
- if (repliesByRootId && repliesByRootId.size) {
2416
- visibleActivitiesCount += repliesByRootId.size || 0;
2417
- }
2418
- } // stop fetching if we've reached desired count of visible activities
2419
-
2420
- } catch (err) {
2421
- _iterator5.e(err);
2422
- } finally {
2423
- _iterator5.f();
2424
- }
2425
-
2426
- if (!(visibleActivitiesCount >= minActivities)) {
2427
- _context10.next = 41;
2428
- break;
2429
- }
2430
-
2431
- return _context10.abrupt("return", "break");
2432
-
2433
- case 41:
2434
- checkAndSetNoMoreActs(queryType, visibleActivitiesCount, batchSize); // batchSize should be equal to minimum activities when fetching older activities
2435
- // covers "best case" when we reach minActivities on the first fetch
2436
-
2437
- if (queryType === _activities.OLDER) {
2438
- batchSize = minActivities;
2439
- } // since a MID query can bump the batchSize, we need to reset it _after_ a potential MID query
2440
- // reset batchSize in case of MID queries bumping it up
2441
-
2442
-
2443
- if (queryType === _activities.NEWER) {
2444
- batchSize = defaultBatchSize;
2445
- }
2446
-
2447
- currentOldestPublishedDate = (0, _activities.getPublishedDate)(getOldestAct());
2448
- currentNewestPublishedDate = (0, _activities.getPublishedDate)(getNewestAct()); // we're still building our activity list - derive new query from prior query and start loop again
2449
-
2450
- if (queryType === _activities.INITIAL) {
2451
- query = (0, _activityThreadOrdering.getQuery)(_activities.OLDER, {
2452
- oldestPublishedDate: currentOldestPublishedDate,
2453
- batchSize: batchSize
2454
- });
2455
- } else {
2456
- query = (0, _activityThreadOrdering.getQuery)(queryType, {
2457
- batchSize: batchSize,
2458
- activityToSearch: search,
2459
- oldestPublishedDate: currentOldestPublishedDate,
2460
- newestPublishedDate: currentNewestPublishedDate
2461
- });
2462
- } // if we're still building out the midDate search, bump the search limit to include activities on both sides
2463
-
2464
-
2465
- if (queryType === _activities.MID) {
2466
- batchSize += _activityThreadOrdering.batchSizeIncrementCount;
2467
- }
2468
-
2469
- case 48:
2470
- case "end":
2471
- return _context10.stop();
1855
+ while (1) switch (_context12.prev = _context12.next) {
1856
+ case 0:
1857
+ // ***********************************************
1858
+ // INSTANCE STATE VARIABLES
1859
+ // variables that will be used for the life of the generator
1860
+ // ***********************************************
1861
+ _options$minActivitie = options.minActivities, minActivities = _options$minActivitie === void 0 ? _activityThreadOrdering.defaultMinDisplayableActivities : _options$minActivitie, _options$queryType = options.queryType, queryType = _options$queryType === void 0 ? _activities.INITIAL : _options$queryType; // must fetch initially before getting newer activities!
1862
+ if (queryType === _activities.NEWER) {
1863
+ queryType = _activities.INITIAL;
1864
+ }
1865
+ convoUrl = options.url, _options$search = options.search, search = _options$search === void 0 ? {} : _options$search, includeChildren = options.includeChildren; // manage oldest, newest activities (ie bookends)
1866
+ _bookendManager = (0, _activityThreadOrdering.bookendManager)(), setBookends = _bookendManager.setBookends, getNewestAct = _bookendManager.getNewestAct, getOldestAct = _bookendManager.getOldestAct; // default batch should be equal to minActivities when fetching back in time, but halved when fetching newer due to subsequent child fetches filling up the minActivities count
1867
+ // reduces server RTs when fetching older activities
1868
+ defaultBatchSize = queryType === _activities.INITIAL || queryType === _activities.OLDER ? minActivities : Math.max(_activityThreadOrdering.minBatchSize, Math.ceil(minActivities / 2));
1869
+ batchSize = defaultBatchSize; // exposes activity states and handlers with simple getters
1870
+ _activityManager = (0, _activityThreadOrdering.activityManager)(), getActivityHandlerByKey = _activityManager.getActivityHandlerByKey, getActivityByTypeAndParentId = _activityManager.getActivityByTypeAndParentId; // set initial query
1871
+ query = (0, _activityThreadOrdering.getQuery)(queryType, {
1872
+ activityToSearch: search,
1873
+ batchSize: batchSize
1874
+ });
1875
+ /* eslint-disable no-await-in-loop */
1876
+ /* eslint-disable no-loop-func */
1877
+ _loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
1878
+ var _rootActivityManager, getRootActivityHash, addNewRoot, _noMoreActivitiesMana, getNoMoreActs, checkAndSetNoMoreActs, checkAndSetNoOlderActs, checkAndSetNoNewerActs, getActivityHandlerByType, handleNewActivity, handleNewActivities, handleOlderQuery, handleNewerQuery, handleSearch, getQueryResponseHandler, incrementLoopCounter, _loop2, _ret2, orderedActivities, getRepliesByParentId, orderedRoots, nextOptions, currentOldestPublishedDate, currentNewestPublishedDate;
1879
+ return _regenerator.default.wrap(function _loop$(_context11) {
1880
+ while (1) switch (_context11.prev = _context11.next) {
1881
+ case 0:
1882
+ // ***********************************************
1883
+ // EXECUTION STATE VARIABLES
1884
+ // variables that will be used for each "batch" of activities asked for
1885
+ // ***********************************************
1886
+ // stores all "root" activities (activities that are, or could be, thread parents)
1887
+ _rootActivityManager = (0, _activityThreadOrdering.rootActivityManager)(), getRootActivityHash = _rootActivityManager.getRootActivityHash, addNewRoot = _rootActivityManager.addNewRoot; // used to determine if we should continue to fetch older activities
1888
+ // must be set per iteration, as querying newer activities is still valid when all end of convo has been reached
1889
+ _noMoreActivitiesMana = (0, _activityThreadOrdering.noMoreActivitiesManager)(), getNoMoreActs = _noMoreActivitiesMana.getNoMoreActs, checkAndSetNoMoreActs = _noMoreActivitiesMana.checkAndSetNoMoreActs, checkAndSetNoOlderActs = _noMoreActivitiesMana.checkAndSetNoOlderActs, checkAndSetNoNewerActs = _noMoreActivitiesMana.checkAndSetNoNewerActs;
1890
+ getActivityHandlerByType = function getActivityHandlerByType(type) {
1891
+ var _ACTIVITY_TYPES$ROOT$;
1892
+ return (_ACTIVITY_TYPES$ROOT$ = {}, (0, _defineProperty2.default)(_ACTIVITY_TYPES$ROOT$, _activities.ACTIVITY_TYPES.ROOT, addNewRoot), (0, _defineProperty2.default)(_ACTIVITY_TYPES$ROOT$, _activities.ACTIVITY_TYPES.REPLY, getActivityHandlerByKey(_activities.ACTIVITY_TYPES.REPLY)), (0, _defineProperty2.default)(_ACTIVITY_TYPES$ROOT$, _activities.ACTIVITY_TYPES.EDIT, getActivityHandlerByKey(_activities.ACTIVITY_TYPES.EDIT)), (0, _defineProperty2.default)(_ACTIVITY_TYPES$ROOT$, _activities.ACTIVITY_TYPES.REACTION, getActivityHandlerByKey(_activities.ACTIVITY_TYPES.REACTION)), (0, _defineProperty2.default)(_ACTIVITY_TYPES$ROOT$, _activities.ACTIVITY_TYPES.REACTION_SELF, getActivityHandlerByKey(_activities.ACTIVITY_TYPES.REACTION_SELF)), (0, _defineProperty2.default)(_ACTIVITY_TYPES$ROOT$, _activities.ACTIVITY_TYPES.TOMBSTONE, addNewRoot), (0, _defineProperty2.default)(_ACTIVITY_TYPES$ROOT$, _activities.ACTIVITY_TYPES.CREATE, addNewRoot), _ACTIVITY_TYPES$ROOT$)[type];
1893
+ };
1894
+ handleNewActivity = function handleNewActivity(activity) {
1895
+ var actType = (0, _activities.getActivityType)(activity);
1896
+
1897
+ // ignore deletes
1898
+ if ((0, _activities.isDeleteActivity)(activity)) {
1899
+ return;
1900
+ }
1901
+ var activityHandler = getActivityHandlerByType(actType);
1902
+ activityHandler(activity);
1903
+ };
1904
+ handleNewActivities = function handleNewActivities(activities) {
1905
+ activities.forEach(function (act) {
1906
+ handleNewActivity(act);
1907
+ checkAndSetNoOlderActs(act);
1908
+ });
1909
+ };
1910
+ handleOlderQuery = function handleOlderQuery(activities) {
1911
+ setBookends(activities, _activities.OLDER);
1912
+ handleNewActivities(activities);
1913
+ };
1914
+ handleNewerQuery = function handleNewerQuery(activities) {
1915
+ checkAndSetNoNewerActs(activities);
1916
+ if (activities.length) {
1917
+ setBookends(activities, _activities.NEWER);
1918
+ handleNewActivities(activities);
1919
+ }
1920
+ };
1921
+ handleSearch = function handleSearch(activities) {
1922
+ setBookends(activities, _activities.MID);
1923
+ handleNewActivities(activities);
1924
+ };
1925
+ getQueryResponseHandler = function getQueryResponseHandler(type) {
1926
+ var _OLDER$NEWER$MID$INIT;
1927
+ return (_OLDER$NEWER$MID$INIT = {}, (0, _defineProperty2.default)(_OLDER$NEWER$MID$INIT, _activities.OLDER, handleOlderQuery), (0, _defineProperty2.default)(_OLDER$NEWER$MID$INIT, _activities.NEWER, handleNewerQuery), (0, _defineProperty2.default)(_OLDER$NEWER$MID$INIT, _activities.MID, handleSearch), (0, _defineProperty2.default)(_OLDER$NEWER$MID$INIT, _activities.INITIAL, handleOlderQuery), _OLDER$NEWER$MID$INIT)[type];
1928
+ }; // ***********************************************
1929
+ // INNER LOOP
1930
+ // responsible for fetching and building our maps of activities
1931
+ // fetch until minActivities is reached, or no more acts to fetch, or we hit our max fetch count
1932
+ // ***********************************************
1933
+ incrementLoopCounter = (0, _activityThreadOrdering.getLoopCounterFailsafe)();
1934
+ _loop2 = /*#__PURE__*/_regenerator.default.mark(function _loop2() {
1935
+ var allBatchActivitiesConfig, $allBatchActivitiesFetch, $fetchRequests, params, $parentsFetch, _yield$_awaitAsyncGen, _yield$_awaitAsyncGen2, allBatchActivities, _yield$_awaitAsyncGen3, parents, handler, _parents$reply, replyIds, _parents$edit, editIds, _parents$reaction, reactionIds, $reactionFetches, $replyFetches, $editFetches, _iterator4, _step4, activity, actId, childFetchOptions, _yield$_awaitAsyncGen4, _yield$_awaitAsyncGen5, reactions, replies, edits, newReplyReactions, allReactions, rootActivityHash, visibleActivitiesCount, _iterator5, _step5, rootActivity, rootId, repliesByRootId, currentOldestPublishedDate, currentNewestPublishedDate;
1936
+ return _regenerator.default.wrap(function _loop2$(_context10) {
1937
+ while (1) switch (_context10.prev = _context10.next) {
1938
+ case 0:
1939
+ // count loops and throw if we detect infinite loop
1940
+ incrementLoopCounter();
1941
+
1942
+ // configure fetch request. Use a smaller limit when fetching newer or mids to account for potential children fetches
1943
+ allBatchActivitiesConfig = _objectSpread({
1944
+ conversationUrl: convoUrl,
1945
+ limit: batchSize,
1946
+ includeChildren: includeChildren
1947
+ }, query); // request activities in batches
1948
+ $allBatchActivitiesFetch = _this.listActivities(allBatchActivitiesConfig); // contain fetches in array to parallelize fetching as needed
1949
+ $fetchRequests = [$allBatchActivitiesFetch]; // if query requires recursive fetches for children acts, add the additional fetch
1950
+ if (queryType === _activities.MID || queryType === _activities.NEWER) {
1951
+ params = {
1952
+ activityType: null
1953
+ };
1954
+ if (query.sinceDate) {
1955
+ params.sinceDate = query.sinceDate;
2472
1956
  }
1957
+ $parentsFetch = _this.listParentActivityIds(convoUrl, params);
1958
+ $fetchRequests.push($parentsFetch);
2473
1959
  }
2474
- }, _loop2);
2475
- });
2476
1960
 
2477
- case 11:
2478
- if (getNoMoreActs()) {
2479
- _context11.next = 18;
2480
- break;
2481
- }
2482
-
2483
- return _context11.delegateYield(_loop2(), "t0", 13);
2484
-
2485
- case 13:
2486
- _ret2 = _context11.t0;
2487
-
2488
- if (!(_ret2 === "break")) {
2489
- _context11.next = 16;
2490
- break;
2491
- }
2492
-
2493
- return _context11.abrupt("break", 18);
2494
-
2495
- case 16:
2496
- _context11.next = 11;
2497
- break;
2498
-
2499
- case 18:
2500
- orderedActivities = [];
2501
-
2502
- getRepliesByParentId = function getRepliesByParentId(replyParentId) {
2503
- var replies = [];
2504
- var repliesByParentId = getActivityByTypeAndParentId(_activities.ACTIVITY_TYPES.REPLY, replyParentId);
2505
-
2506
- if (!repliesByParentId) {
2507
- return replies;
2508
- }
2509
-
2510
- var sortedReplies = (0, _activities.sortActivitiesByPublishedDate)((0, _activityThreadOrdering.getActivityObjectsFromMap)(repliesByParentId));
2511
- sortedReplies.forEach(function (replyActivity) {
2512
- var replyId = replyActivity.id;
2513
- var edit = getActivityByTypeAndParentId(_activities.ACTIVITY_TYPES.EDIT, replyId);
2514
- var reaction = getActivityByTypeAndParentId(_activities.ACTIVITY_TYPES.REACTION, replyId);
2515
- var reactionSelf = getActivityByTypeAndParentId(_activities.ACTIVITY_TYPES.REACTION_SELF, replyId);
2516
- var latestActivity = edit || replyActivity; // hash of root activities (in case of plain reply) and the reply activity (in case of edit)
2517
-
2518
- var allRelevantActivitiesArr = [].concat((0, _toConsumableArray2.default)((0, _activityThreadOrdering.getActivityObjectsFromMap)(getRootActivityHash())), (0, _toConsumableArray2.default)((0, _activityThreadOrdering.getActivityObjectsFromMap)(repliesByParentId)));
2519
- var allRelevantActivities = allRelevantActivitiesArr.reduce(function (hashMap, act) {
2520
- hashMap[act.id] = act;
2521
- return hashMap;
2522
- }, {});
2523
-
2524
- var finalReply = _this._createParsedServerActivity(latestActivity, allRelevantActivities);
2525
-
2526
- var fullReply = {
2527
- id: replyId,
2528
- activity: finalReply,
2529
- reaction: reaction,
2530
- reactionSelf: reactionSelf
2531
- };
2532
- var sanitizedFullReply = (0, _activities.sanitizeActivity)(fullReply);
2533
- replies.push(sanitizedFullReply);
2534
- });
2535
- return replies;
2536
- };
2537
-
2538
- orderedRoots = (0, _activities.sortActivitiesByPublishedDate)((0, _activityThreadOrdering.getActivityObjectsFromMap)(getRootActivityHash()));
2539
- orderedRoots.forEach(function (rootActivity) {
2540
- var rootId = rootActivity.id;
2541
- var replies = getRepliesByParentId(rootId);
2542
- var edit = getActivityByTypeAndParentId(_activities.ACTIVITY_TYPES.EDIT, rootId);
2543
- var reaction = getActivityByTypeAndParentId(_activities.ACTIVITY_TYPES.REACTION, rootId);
2544
- var reactionSelf = getActivityByTypeAndParentId(_activities.ACTIVITY_TYPES.REACTION_SELF, rootId);
2545
- var latestActivity = edit || rootActivity;
1961
+ // we dont always need to fetch for parents
1962
+ _context10.next = 7;
1963
+ return (0, _awaitAsyncGenerator2.default)(_promise.default.all($fetchRequests));
1964
+ case 7:
1965
+ _yield$_awaitAsyncGen = _context10.sent;
1966
+ _yield$_awaitAsyncGen2 = (0, _slicedToArray2.default)(_yield$_awaitAsyncGen, 2);
1967
+ allBatchActivities = _yield$_awaitAsyncGen2[0];
1968
+ _yield$_awaitAsyncGen3 = _yield$_awaitAsyncGen2[1];
1969
+ parents = _yield$_awaitAsyncGen3 === void 0 ? {} : _yield$_awaitAsyncGen3;
1970
+ // use query type to decide how to handle response
1971
+ handler = getQueryResponseHandler(queryType);
1972
+ handler(allBatchActivities);
1973
+
1974
+ /*
1975
+ next we must selectively fetch the children of each of the parents to ensure completeness
1976
+ do this by checking the hash for each of the above parent IDs
1977
+ fetch children when we have a parent whose ID is represented in the parent ID lists
1978
+ */
1979
+ _parents$reply = parents.reply, replyIds = _parents$reply === void 0 ? [] : _parents$reply, _parents$edit = parents.edit, editIds = _parents$edit === void 0 ? [] : _parents$edit, _parents$reaction = parents.reaction, reactionIds = _parents$reaction === void 0 ? [] : _parents$reaction; // if no parent IDs returned, do nothing
1980
+ if (!(replyIds.length || editIds.length || reactionIds.length)) {
1981
+ _context10.next = 35;
1982
+ break;
1983
+ }
1984
+ $reactionFetches = [];
1985
+ $replyFetches = [];
1986
+ $editFetches = [];
1987
+ _iterator4 = _createForOfIteratorHelper(allBatchActivities);
1988
+ try {
1989
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
1990
+ activity = _step4.value;
1991
+ actId = activity.id;
1992
+ childFetchOptions = {
1993
+ conversationUrl: convoUrl,
1994
+ activityParentId: actId
1995
+ };
1996
+ if (reactionIds.includes(actId)) {
1997
+ $reactionFetches.push(_this.getReactionSummaryByParentId(convoUrl, actId, {
1998
+ activityType: 'reactionSummary',
1999
+ includeChildren: true
2000
+ }));
2001
+ }
2002
+ if (replyIds.includes(actId)) {
2003
+ childFetchOptions.query = {
2004
+ activityType: 'reply'
2005
+ };
2006
+ $replyFetches.push(_this.listAllChildActivitiesByParentId(childFetchOptions));
2007
+ }
2008
+ if (editIds.includes(actId)) {
2009
+ childFetchOptions.query = {
2010
+ activityType: 'edit'
2011
+ };
2012
+ $editFetches.push(_this.listAllChildActivitiesByParentId(childFetchOptions));
2013
+ }
2014
+ }
2546
2015
 
2547
- var finalActivity = _this._createParsedServerActivity(latestActivity, (0, _defineProperty2.default)({}, rootId, rootActivity));
2016
+ // parallelize fetch for speeedz
2017
+ } catch (err) {
2018
+ _iterator4.e(err);
2019
+ } finally {
2020
+ _iterator4.f();
2021
+ }
2022
+ _context10.next = 23;
2023
+ return (0, _awaitAsyncGenerator2.default)(_promise.default.all([_promise.default.all($reactionFetches), _promise.default.all($replyFetches), _promise.default.all($editFetches)]));
2024
+ case 23:
2025
+ _yield$_awaitAsyncGen4 = _context10.sent;
2026
+ _yield$_awaitAsyncGen5 = (0, _slicedToArray2.default)(_yield$_awaitAsyncGen4, 3);
2027
+ reactions = _yield$_awaitAsyncGen5[0];
2028
+ replies = _yield$_awaitAsyncGen5[1];
2029
+ edits = _yield$_awaitAsyncGen5[2];
2030
+ _context10.next = 30;
2031
+ return (0, _awaitAsyncGenerator2.default)(_promise.default.all(replies.filter(function (reply) {
2032
+ return replyIds.includes(reply.id);
2033
+ }).map(function (reply) {
2034
+ return _this.getReactionSummaryByParentId(convoUrl, reply.id, {
2035
+ activityType: 'reactionSummary',
2036
+ includeChildren: true
2037
+ });
2038
+ })));
2039
+ case 30:
2040
+ newReplyReactions = _context10.sent;
2041
+ allReactions = [].concat((0, _toConsumableArray2.default)(reactions), (0, _toConsumableArray2.default)(newReplyReactions)); // stick them into activity hashes
2042
+ replies.forEach(function (replyArr) {
2043
+ return handleNewActivities(replyArr);
2044
+ });
2045
+ edits.forEach(function (editArr) {
2046
+ return handleNewActivities(editArr);
2047
+ });
2048
+ allReactions.forEach(function (reactionArr) {
2049
+ return handleNewActivities(reactionArr);
2050
+ });
2051
+ case 35:
2052
+ rootActivityHash = getRootActivityHash();
2053
+ visibleActivitiesCount = rootActivityHash.size;
2054
+ _iterator5 = _createForOfIteratorHelper(rootActivityHash.values());
2055
+ try {
2056
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
2057
+ rootActivity = _step5.value;
2058
+ rootId = rootActivity.id;
2059
+ repliesByRootId = getActivityByTypeAndParentId(_activities.ACTIVITY_TYPES.REPLY, rootId);
2060
+ if (repliesByRootId && repliesByRootId.size) {
2061
+ visibleActivitiesCount += repliesByRootId.size || 0;
2062
+ }
2063
+ }
2548
2064
 
2549
- var fullRoot = {
2550
- id: rootId,
2551
- activity: finalActivity,
2552
- reaction: reaction,
2553
- reactionSelf: reactionSelf
2554
- };
2555
- var sanitizedFullRoot = (0, _activities.sanitizeActivity)(fullRoot);
2556
- orderedActivities.push(sanitizedFullRoot);
2557
- replies.forEach(function (reply) {
2558
- return orderedActivities.push(reply);
2559
- });
2560
- });
2561
- _context11.next = 24;
2562
- return orderedActivities;
2065
+ // stop fetching if we've reached desired count of visible activities
2066
+ } catch (err) {
2067
+ _iterator5.e(err);
2068
+ } finally {
2069
+ _iterator5.f();
2070
+ }
2071
+ if (!(visibleActivitiesCount >= minActivities)) {
2072
+ _context10.next = 41;
2073
+ break;
2074
+ }
2075
+ return _context10.abrupt("return", "break");
2076
+ case 41:
2077
+ checkAndSetNoMoreActs(queryType, visibleActivitiesCount, batchSize);
2078
+
2079
+ // batchSize should be equal to minimum activities when fetching older activities
2080
+ // covers "best case" when we reach minActivities on the first fetch
2081
+ if (queryType === _activities.OLDER) {
2082
+ batchSize = minActivities;
2083
+ }
2563
2084
 
2564
- case 24:
2565
- nextOptions = _context11.sent;
2085
+ // since a MID query can bump the batchSize, we need to reset it _after_ a potential MID query
2086
+ // reset batchSize in case of MID queries bumping it up
2087
+ if (queryType === _activities.NEWER) {
2088
+ batchSize = defaultBatchSize;
2089
+ }
2090
+ currentOldestPublishedDate = (0, _activities.getPublishedDate)(getOldestAct());
2091
+ currentNewestPublishedDate = (0, _activities.getPublishedDate)(getNewestAct()); // we're still building our activity list - derive new query from prior query and start loop again
2092
+ if (queryType === _activities.INITIAL) {
2093
+ query = (0, _activityThreadOrdering.getQuery)(_activities.OLDER, {
2094
+ oldestPublishedDate: currentOldestPublishedDate,
2095
+ batchSize: batchSize
2096
+ });
2097
+ } else {
2098
+ query = (0, _activityThreadOrdering.getQuery)(queryType, {
2099
+ batchSize: batchSize,
2100
+ activityToSearch: search,
2101
+ oldestPublishedDate: currentOldestPublishedDate,
2102
+ newestPublishedDate: currentNewestPublishedDate
2103
+ });
2104
+ }
2566
2105
 
2567
- if (!nextOptions) {
2568
- _context11.next = 33;
2569
- break;
2106
+ // if we're still building out the midDate search, bump the search limit to include activities on both sides
2107
+ if (queryType === _activities.MID) {
2108
+ batchSize += _activityThreadOrdering.batchSizeIncrementCount;
2109
+ }
2110
+ case 48:
2111
+ case "end":
2112
+ return _context10.stop();
2570
2113
  }
2571
-
2572
- minActivities = nextOptions.minActivities || minActivities;
2573
- currentOldestPublishedDate = (0, _activities.getPublishedDate)(getOldestAct());
2574
- currentNewestPublishedDate = (0, _activities.getPublishedDate)(getNewestAct());
2575
- queryType = nextOptions.queryType;
2576
- query = (0, _activityThreadOrdering.getQuery)(queryType, {
2577
- activityToSearch: search,
2578
- oldestPublishedDate: currentOldestPublishedDate,
2579
- newestPublishedDate: currentNewestPublishedDate,
2580
- batchSize: batchSize
2581
- });
2582
- _context11.next = 34;
2583
- break;
2584
-
2585
- case 33:
2586
- return _context11.abrupt("return", {
2587
- v: void 0
2588
- });
2589
-
2590
- case 34:
2591
- case "end":
2592
- return _context11.stop();
2114
+ }, _loop2);
2115
+ });
2116
+ case 11:
2117
+ if (getNoMoreActs()) {
2118
+ _context11.next = 18;
2119
+ break;
2593
2120
  }
2594
- }
2595
- }, _loop);
2596
- });
2597
-
2598
- case 9:
2599
- if (!true) {
2600
- _context12.next = 16;
2601
- break;
2602
- }
2603
-
2604
- return _context12.delegateYield(_loop(), "t0", 11);
2605
-
2606
- case 11:
2607
- _ret = _context12.t0;
2608
-
2609
- if (!((0, _typeof2.default)(_ret) === "object")) {
2610
- _context12.next = 14;
2611
- break;
2612
- }
2613
-
2614
- return _context12.abrupt("return", _ret.v);
2615
-
2616
- case 14:
2617
- _context12.next = 9;
2121
+ return _context11.delegateYield(_loop2(), "t0", 13);
2122
+ case 13:
2123
+ _ret2 = _context11.t0;
2124
+ if (!(_ret2 === "break")) {
2125
+ _context11.next = 16;
2126
+ break;
2127
+ }
2128
+ return _context11.abrupt("break", 18);
2129
+ case 16:
2130
+ _context11.next = 11;
2131
+ break;
2132
+ case 18:
2133
+ orderedActivities = [];
2134
+ getRepliesByParentId = function getRepliesByParentId(replyParentId) {
2135
+ var replies = [];
2136
+ var repliesByParentId = getActivityByTypeAndParentId(_activities.ACTIVITY_TYPES.REPLY, replyParentId);
2137
+ if (!repliesByParentId) {
2138
+ return replies;
2139
+ }
2140
+ var sortedReplies = (0, _activities.sortActivitiesByPublishedDate)((0, _activityThreadOrdering.getActivityObjectsFromMap)(repliesByParentId));
2141
+ sortedReplies.forEach(function (replyActivity) {
2142
+ var replyId = replyActivity.id;
2143
+ var edit = getActivityByTypeAndParentId(_activities.ACTIVITY_TYPES.EDIT, replyId);
2144
+ var reaction = getActivityByTypeAndParentId(_activities.ACTIVITY_TYPES.REACTION, replyId);
2145
+ var reactionSelf = getActivityByTypeAndParentId(_activities.ACTIVITY_TYPES.REACTION_SELF, replyId);
2146
+ var latestActivity = edit || replyActivity;
2147
+ // hash of root activities (in case of plain reply) and the reply activity (in case of edit)
2148
+ var allRelevantActivitiesArr = [].concat((0, _toConsumableArray2.default)((0, _activityThreadOrdering.getActivityObjectsFromMap)(getRootActivityHash())), (0, _toConsumableArray2.default)((0, _activityThreadOrdering.getActivityObjectsFromMap)(repliesByParentId)));
2149
+ var allRelevantActivities = allRelevantActivitiesArr.reduce(function (hashMap, act) {
2150
+ hashMap[act.id] = act;
2151
+ return hashMap;
2152
+ }, {});
2153
+ var finalReply = _this._createParsedServerActivity(latestActivity, allRelevantActivities);
2154
+ var fullReply = {
2155
+ id: replyId,
2156
+ activity: finalReply,
2157
+ reaction: reaction,
2158
+ reactionSelf: reactionSelf
2159
+ };
2160
+ var sanitizedFullReply = (0, _activities.sanitizeActivity)(fullReply);
2161
+ replies.push(sanitizedFullReply);
2162
+ });
2163
+ return replies;
2164
+ };
2165
+ orderedRoots = (0, _activities.sortActivitiesByPublishedDate)((0, _activityThreadOrdering.getActivityObjectsFromMap)(getRootActivityHash()));
2166
+ orderedRoots.forEach(function (rootActivity) {
2167
+ var rootId = rootActivity.id;
2168
+ var replies = getRepliesByParentId(rootId);
2169
+ var edit = getActivityByTypeAndParentId(_activities.ACTIVITY_TYPES.EDIT, rootId);
2170
+ var reaction = getActivityByTypeAndParentId(_activities.ACTIVITY_TYPES.REACTION, rootId);
2171
+ var reactionSelf = getActivityByTypeAndParentId(_activities.ACTIVITY_TYPES.REACTION_SELF, rootId);
2172
+ var latestActivity = edit || rootActivity;
2173
+ var finalActivity = _this._createParsedServerActivity(latestActivity, (0, _defineProperty2.default)({}, rootId, rootActivity));
2174
+ var fullRoot = {
2175
+ id: rootId,
2176
+ activity: finalActivity,
2177
+ reaction: reaction,
2178
+ reactionSelf: reactionSelf
2179
+ };
2180
+ var sanitizedFullRoot = (0, _activities.sanitizeActivity)(fullRoot);
2181
+ orderedActivities.push(sanitizedFullRoot);
2182
+ replies.forEach(function (reply) {
2183
+ return orderedActivities.push(reply);
2184
+ });
2185
+ });
2186
+ _context11.next = 24;
2187
+ return orderedActivities;
2188
+ case 24:
2189
+ nextOptions = _context11.sent;
2190
+ if (!nextOptions) {
2191
+ _context11.next = 33;
2192
+ break;
2193
+ }
2194
+ minActivities = nextOptions.minActivities || minActivities;
2195
+ currentOldestPublishedDate = (0, _activities.getPublishedDate)(getOldestAct());
2196
+ currentNewestPublishedDate = (0, _activities.getPublishedDate)(getNewestAct());
2197
+ queryType = nextOptions.queryType;
2198
+ query = (0, _activityThreadOrdering.getQuery)(queryType, {
2199
+ activityToSearch: search,
2200
+ oldestPublishedDate: currentOldestPublishedDate,
2201
+ newestPublishedDate: currentNewestPublishedDate,
2202
+ batchSize: batchSize
2203
+ });
2204
+ _context11.next = 34;
2205
+ break;
2206
+ case 33:
2207
+ return _context11.abrupt("return", {
2208
+ v: void 0
2209
+ });
2210
+ case 34:
2211
+ case "end":
2212
+ return _context11.stop();
2213
+ }
2214
+ }, _loop);
2215
+ });
2216
+ case 9:
2217
+ if (!true) {
2218
+ _context12.next = 16;
2618
2219
  break;
2619
-
2620
- case 16:
2621
- case "end":
2622
- return _context12.stop();
2623
- }
2220
+ }
2221
+ return _context12.delegateYield(_loop(), "t0", 11);
2222
+ case 11:
2223
+ _ret = _context12.t0;
2224
+ if (!((0, _typeof2.default)(_ret) === "object")) {
2225
+ _context12.next = 14;
2226
+ break;
2227
+ }
2228
+ return _context12.abrupt("return", _ret.v);
2229
+ case 14:
2230
+ _context12.next = 9;
2231
+ break;
2232
+ case 16:
2233
+ case "end":
2234
+ return _context12.stop();
2624
2235
  }
2625
2236
  }, _callee10);
2626
2237
  }))();
2627
2238
  },
2628
-
2629
2239
  /**
2630
2240
  * @typedef {object} EditActivity
2631
2241
  * @property {object} editParent
@@ -2639,13 +2249,11 @@ var Conversation = _webexCore.WebexPlugin.extend({
2639
2249
  *
2640
2250
  * @typedef {EditActivity | ReplyActivity | EditedReplyActivity} ParsedServerActivity
2641
2251
  */
2642
-
2643
2252
  /**
2644
2253
  * hashmap of server activities, keyed by id
2645
2254
  * @typedef {object} ActivityHash
2646
2255
  * @property {Object}
2647
2256
  */
2648
-
2649
2257
  /**
2650
2258
  * extends a given server object with fields that point to their parent activities from the hashmap passed in
2651
2259
  * @param {object} activity server activity
@@ -2655,43 +2263,35 @@ var Conversation = _webexCore.WebexPlugin.extend({
2655
2263
  _createParsedServerActivity: function _createParsedServerActivity(activity) {
2656
2264
  var allActivitiesHash = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2657
2265
  var isOrphan = (0, _activities.getIsActivityOrphaned)(activity, allActivitiesHash);
2658
-
2659
2266
  if (isOrphan) {
2660
2267
  throw new Error('activity has a parent that cannot be found in allActivitiesHash! please handle this as necessary');
2661
2268
  }
2662
-
2663
2269
  var activityType = (0, _activities.determineActivityType)(activity, allActivitiesHash);
2664
-
2665
2270
  switch (activityType) {
2666
2271
  case _activities.ACTIVITY_TYPES.ROOT:
2667
2272
  {
2668
2273
  return (0, _activities.createRootActivity)(activity);
2669
2274
  }
2670
-
2671
2275
  case _activities.ACTIVITY_TYPES.EDIT:
2672
2276
  {
2673
2277
  // `activities` must also have the original activity
2674
2278
  return (0, _activities.createEditActivity)(activity, allActivitiesHash);
2675
2279
  }
2676
-
2677
2280
  case _activities.ACTIVITY_TYPES.REPLY:
2678
2281
  {
2679
2282
  return (0, _activities.createReplyActivity)(activity);
2680
2283
  }
2681
-
2682
2284
  case _activities.ACTIVITY_TYPES.REPLY_EDIT:
2683
2285
  {
2684
2286
  // `activities` must also have the reply activity
2685
2287
  return (0, _activities.createReplyEditActivity)(activity, allActivitiesHash);
2686
2288
  }
2687
-
2688
2289
  default:
2689
2290
  {
2690
2291
  return activity;
2691
2292
  }
2692
2293
  }
2693
2294
  },
2694
-
2695
2295
  /**
2696
2296
  * @param {Object} options
2697
2297
  * @private
@@ -2699,119 +2299,97 @@ var Conversation = _webexCore.WebexPlugin.extend({
2699
2299
  */
2700
2300
  _list: function _list(options) {
2701
2301
  var _this30 = this;
2702
-
2703
2302
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
2704
2303
  var res, list, limit, results, _iterator6, _step6, result, items;
2705
-
2706
2304
  return _regenerator.default.wrap(function _callee11$(_context13) {
2707
- while (1) {
2708
- switch (_context13.prev = _context13.next) {
2709
- case 0:
2710
- options.qs = _objectSpread({
2711
- personRefresh: true,
2712
- uuidEntryFormat: true,
2713
- activitiesLimit: 0,
2714
- participantsLimit: 0
2715
- }, options.qs);
2716
- _context13.next = 3;
2717
- return _this30.request(options);
2718
-
2719
- case 3:
2720
- res = _context13.sent;
2721
-
2722
- if (!res.body || !res.body.items || res.body.items.length === 0) {
2723
- list = [];
2724
- } else {
2725
- list = res.body.items.slice(0);
2726
-
2727
- if ((0, _last2.default)(list).published < list[0].published) {
2728
- list.reverse();
2729
- }
2730
- } // The user has more data in another cluster.
2731
- // Follow the 'additionalUrls' for that data.
2732
-
2733
-
2734
- if (!res.body.additionalUrls) {
2735
- _context13.next = 14;
2736
- break;
2305
+ while (1) switch (_context13.prev = _context13.next) {
2306
+ case 0:
2307
+ options.qs = _objectSpread({
2308
+ personRefresh: true,
2309
+ uuidEntryFormat: true,
2310
+ activitiesLimit: 0,
2311
+ participantsLimit: 0
2312
+ }, options.qs);
2313
+ _context13.next = 3;
2314
+ return _this30.request(options);
2315
+ case 3:
2316
+ res = _context13.sent;
2317
+ if (!res.body || !res.body.items || res.body.items.length === 0) {
2318
+ list = [];
2319
+ } else {
2320
+ list = res.body.items.slice(0);
2321
+ if ((0, _last2.default)(list).published < list[0].published) {
2322
+ list.reverse();
2737
2323
  }
2324
+ }
2738
2325
 
2739
- limit = 0; // If the user asked for a specific amount of data,
2740
- // don't fetch more than what was asked.
2741
- // Here we figure out how much is left from the original request.
2742
- // Divide that by the number of additional URLS.
2743
- // This won't get us the exact limit but it will retrieve something
2744
- // from every cluster listed.
2326
+ // The user has more data in another cluster.
2327
+ // Follow the 'additionalUrls' for that data.
2328
+ if (!res.body.additionalUrls) {
2329
+ _context13.next = 14;
2330
+ break;
2331
+ }
2332
+ limit = 0; // If the user asked for a specific amount of data,
2333
+ // don't fetch more than what was asked.
2334
+ // Here we figure out how much is left from the original request.
2335
+ // Divide that by the number of additional URLS.
2336
+ // This won't get us the exact limit but it will retrieve something
2337
+ // from every cluster listed.
2338
+ if (options.limit) {
2339
+ limit = Math.floor((options.limit.value - list.length) / res.body.additionalUrls.length);
2340
+ }
2745
2341
 
2342
+ // If the limit is 0 for some reason,
2343
+ // don't bother requesting from other clusters
2344
+ if (!(!options.limit || limit !== 0)) {
2345
+ _context13.next = 14;
2346
+ break;
2347
+ }
2348
+ _context13.next = 11;
2349
+ return _promise.default.all(res.body.additionalUrls.map(function (host) {
2350
+ var url = "".concat(host, "/").concat(options.resource);
2351
+ var newOptions = _objectSpread(_objectSpread({}, options), {}, {
2352
+ uri: url,
2353
+ url: url
2354
+ });
2746
2355
  if (options.limit) {
2747
- limit = Math.floor((options.limit.value - list.length) / res.body.additionalUrls.length);
2748
- } // If the limit is 0 for some reason,
2749
- // don't bother requesting from other clusters
2750
-
2751
-
2752
- if (!(!options.limit || limit !== 0)) {
2753
- _context13.next = 14;
2754
- break;
2356
+ newOptions.qs[newOptions.limit.name] = limit;
2755
2357
  }
2756
-
2757
- _context13.next = 11;
2758
- return _promise.default.all(res.body.additionalUrls.map(function (host) {
2759
- var url = "".concat(host, "/").concat(options.resource);
2760
-
2761
- var newOptions = _objectSpread(_objectSpread({}, options), {}, {
2762
- uri: url,
2763
- url: url
2764
- });
2765
-
2766
- if (options.limit) {
2767
- newOptions.qs[newOptions.limit.name] = limit;
2768
- }
2769
-
2770
- return _this30.request(newOptions);
2771
- }));
2772
-
2773
- case 11:
2774
- results = _context13.sent;
2775
- _iterator6 = _createForOfIteratorHelper(results);
2776
-
2777
- try {
2778
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
2779
- result = _step6.value;
2780
-
2781
- if (result.body && result.body.items && result.body.items.length) {
2782
- items = result.body.items;
2783
-
2784
- if ((0, _last2.default)(items).published < items[0].published) {
2785
- items.reverse();
2786
- }
2787
-
2788
- list = list.concat(items);
2358
+ return _this30.request(newOptions);
2359
+ }));
2360
+ case 11:
2361
+ results = _context13.sent;
2362
+ _iterator6 = _createForOfIteratorHelper(results);
2363
+ try {
2364
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
2365
+ result = _step6.value;
2366
+ if (result.body && result.body.items && result.body.items.length) {
2367
+ items = result.body.items;
2368
+ if ((0, _last2.default)(items).published < items[0].published) {
2369
+ items.reverse();
2789
2370
  }
2371
+ list = list.concat(items);
2790
2372
  }
2791
- } catch (err) {
2792
- _iterator6.e(err);
2793
- } finally {
2794
- _iterator6.f();
2795
2373
  }
2796
-
2797
- case 14:
2798
- _context13.next = 16;
2799
- return _promise.default.all(list.map(function (item) {
2800
- return _this30._recordUUIDs(item);
2801
- }));
2802
-
2803
- case 16:
2804
- return _context13.abrupt("return", list);
2805
-
2806
- case 17:
2807
- case "end":
2808
- return _context13.stop();
2809
- }
2374
+ } catch (err) {
2375
+ _iterator6.e(err);
2376
+ } finally {
2377
+ _iterator6.f();
2378
+ }
2379
+ case 14:
2380
+ _context13.next = 16;
2381
+ return _promise.default.all(list.map(function (item) {
2382
+ return _this30._recordUUIDs(item);
2383
+ }));
2384
+ case 16:
2385
+ return _context13.abrupt("return", list);
2386
+ case 17:
2387
+ case "end":
2388
+ return _context13.stop();
2810
2389
  }
2811
2390
  }, _callee11);
2812
2391
  }))();
2813
2392
  },
2814
-
2815
2393
  /**
2816
2394
  * @param {Object} params
2817
2395
  * @param {Object} options
@@ -2820,7 +2398,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
2820
2398
  */
2821
2399
  _maybeCreateOneOnOneThenPost: function _maybeCreateOneOnOneThenPost(params, options) {
2822
2400
  var _this31 = this;
2823
-
2824
2401
  return this.get((0, _defaults2.default)({
2825
2402
  // the use of uniq in Conversation#create guarantees participant[1] will
2826
2403
  // always be the other user
@@ -2838,17 +2415,14 @@ var Conversation = _webexCore.WebexPlugin.extend({
2838
2415
  return conversation;
2839
2416
  });
2840
2417
  }
2841
-
2842
2418
  return conversation;
2843
2419
  }).catch(function (reason) {
2844
2420
  if (reason.statusCode !== 404) {
2845
2421
  return _promise.default.reject(reason);
2846
2422
  }
2847
-
2848
2423
  return _this31._createOneOnOne(params);
2849
2424
  });
2850
2425
  },
2851
-
2852
2426
  /**
2853
2427
  * @param {Object} params
2854
2428
  * @private
@@ -2856,7 +2430,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
2856
2430
  */
2857
2431
  _prepareConversationForCreation: function _prepareConversationForCreation(params) {
2858
2432
  var _this32 = this;
2859
-
2860
2433
  var payload = {
2861
2434
  activities: {
2862
2435
  items: [this.expand('create')]
@@ -2869,22 +2442,18 @@ var Conversation = _webexCore.WebexPlugin.extend({
2869
2442
  keyUris: []
2870
2443
  }
2871
2444
  };
2872
-
2873
2445
  if (params.displayName) {
2874
2446
  payload.displayName = params.displayName;
2875
2447
  }
2876
-
2877
2448
  if (params.tags) {
2878
2449
  payload.tags = params.tags;
2879
2450
  }
2880
-
2881
2451
  params.participants.forEach(function (participant) {
2882
2452
  payload.activities.items.push(_this32.expand('add', {
2883
2453
  objectType: 'person',
2884
2454
  id: participant
2885
2455
  }));
2886
2456
  });
2887
-
2888
2457
  if (params.comment) {
2889
2458
  payload.activities.items.push(this.expand('post', {
2890
2459
  objectType: 'comment',
@@ -2892,7 +2461,6 @@ var Conversation = _webexCore.WebexPlugin.extend({
2892
2461
  displayName: params.comment
2893
2462
  }));
2894
2463
  }
2895
-
2896
2464
  if (!params.isDefaultClassification && params.classificationId) {
2897
2465
  payload.activities.items.push(this.expand('update', {
2898
2466
  objectType: 'classification',
@@ -2900,16 +2468,13 @@ var Conversation = _webexCore.WebexPlugin.extend({
2900
2468
  effectiveDate: params.effectiveDate
2901
2469
  }));
2902
2470
  }
2903
-
2904
2471
  if (params.favorite) {
2905
2472
  payload.activities.items.push(this.expand('favorite', {
2906
2473
  objectType: 'conversation'
2907
2474
  }));
2908
2475
  }
2909
-
2910
2476
  return payload;
2911
2477
  },
2912
-
2913
2478
  /**
2914
2479
  * @param {Object} conversation
2915
2480
  * @private
@@ -2917,30 +2482,25 @@ var Conversation = _webexCore.WebexPlugin.extend({
2917
2482
  */
2918
2483
  _recordUUIDs: function _recordUUIDs(conversation) {
2919
2484
  var _this33 = this;
2920
-
2921
2485
  if (!conversation.participants || !conversation.participants.items) {
2922
2486
  return _promise.default.resolve(conversation);
2923
2487
  }
2924
-
2925
2488
  return _promise.default.all(conversation.participants.items.map(function (participant) {
2926
2489
  // ROOMs or LYRA_SPACEs do not have email addresses, so there's no point attempting to
2927
2490
  // record their UUIDs.
2928
2491
  if (participant.type === 'ROOM' || participant.type === 'LYRA_SPACE') {
2929
2492
  return _promise.default.resolve();
2930
2493
  }
2931
-
2932
2494
  return _this33.webex.internal.user.recordUUID(participant).catch(function (err) {
2933
2495
  return _this33.logger.warn('Could not record uuid', err);
2934
2496
  });
2935
2497
  }));
2936
2498
  },
2937
- version: "3.0.0-beta.15"
2499
+ version: "3.0.0-beta.16"
2938
2500
  });
2939
-
2940
2501
  ['favorite', 'hide', 'lock', 'mute', 'unfavorite', 'unhide', 'unlock', 'unmute'].forEach(function (verb) {
2941
2502
  Conversation.prototype[verb] = function submitSimpleActivity(conversation, activity) {
2942
2503
  var _this34 = this;
2943
-
2944
2504
  var convoWithUrl = this.prepareConversation(_objectSpread(_objectSpread({}, conversation), {}, {
2945
2505
  url: this.getConvoUrl(conversation)
2946
2506
  }));
@@ -2956,16 +2516,13 @@ var Conversation = _webexCore.WebexPlugin.extend({
2956
2516
  ['assignModerator', 'unassignModerator'].forEach(function (verb) {
2957
2517
  Conversation.prototype[verb] = function submitModerationChangeActivity(conversation, moderator, activity) {
2958
2518
  var _this35 = this;
2959
-
2960
2519
  var convoWithUrl = _objectSpread(_objectSpread({}, conversation), {}, {
2961
2520
  url: this.getConvoUrl(conversation)
2962
2521
  });
2963
-
2964
2522
  return _promise.default.all([convoWithUrl, moderator ? this.webex.internal.user.asUUID(moderator) : this.webex.internal.device.userId]).then(function (_ref8) {
2965
2523
  var _ref9 = (0, _slicedToArray2.default)(_ref8, 2),
2966
- c = _ref9[0],
2967
- userId = _ref9[1];
2968
-
2524
+ c = _ref9[0],
2525
+ userId = _ref9[1];
2969
2526
  return _this35.prepare(activity, {
2970
2527
  verb: verb,
2971
2528
  target: _this35.prepareConversation(c),
@@ -2979,6 +2536,7 @@ var Conversation = _webexCore.WebexPlugin.extend({
2979
2536
  });
2980
2537
  };
2981
2538
  });
2539
+
2982
2540
  /**
2983
2541
  * Sets/unsets space property for convo
2984
2542
  * @param {Object} conversation
@@ -2986,21 +2544,16 @@ var Conversation = _webexCore.WebexPlugin.extend({
2986
2544
  * @param {Activity} activity
2987
2545
  * @returns {Promise<Activity>}
2988
2546
  */
2989
-
2990
2547
  ['setSpaceProperty', 'unsetSpaceProperty'].forEach(function (fnName) {
2991
2548
  var verb = fnName.startsWith('set') ? 'set' : 'unset';
2992
-
2993
2549
  Conversation.prototype[fnName] = function submitSpacePropertyActivity(conversation, tag, activity) {
2994
2550
  var _this36 = this;
2995
-
2996
2551
  if (!(0, _isString2.default)(tag)) {
2997
2552
  return _promise.default.reject(new Error('`tag` must be a string'));
2998
2553
  }
2999
-
3000
2554
  var convoWithUrl = _objectSpread(_objectSpread({}, conversation), {}, {
3001
2555
  url: this.getConvoUrl(conversation)
3002
2556
  });
3003
-
3004
2557
  return this.prepare(activity, {
3005
2558
  verb: verb,
3006
2559
  target: this.prepareConversation(convoWithUrl),
@@ -3016,11 +2569,9 @@ var Conversation = _webexCore.WebexPlugin.extend({
3016
2569
  ['tag', 'untag'].forEach(function (verb) {
3017
2570
  Conversation.prototype[verb] = function submitObjectActivity(conversation, object, activity) {
3018
2571
  var _this37 = this;
3019
-
3020
2572
  if (!(0, _isObject2.default)(object)) {
3021
2573
  return _promise.default.reject(new Error('`object` must be an object'));
3022
2574
  }
3023
-
3024
2575
  var c = this.prepareConversation(_objectSpread(_objectSpread({}, conversation), {}, {
3025
2576
  url: this.getConvoUrl(conversation)
3026
2577
  }));