@webex/internal-plugin-conversation 3.0.0-beta.9 → 3.0.0-bnr.2

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