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