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