@webex/internal-plugin-presence 3.5.0-wxcc.1 → 3.6.0
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/dist/presence.js +34 -12
- package/dist/presence.js.map +1 -1
- package/package.json +12 -12
- package/src/presence.js +16 -2
- package/test/unit/spec/presence.js +39 -1
package/dist/presence.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _Object$keys = require("@babel/runtime-corejs2/core-js/object/keys");
|
|
4
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
|
|
5
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
|
|
6
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
|
|
7
|
+
var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
|
|
3
8
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
9
|
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
5
10
|
_Object$defineProperty(exports, "__esModule", {
|
|
6
11
|
value: true
|
|
7
12
|
});
|
|
8
13
|
exports.default = void 0;
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
9
15
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
|
|
10
16
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
11
17
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/array/is-array"));
|
|
@@ -13,10 +19,10 @@ require("@webex/internal-plugin-device");
|
|
|
13
19
|
var _webexCore = require("@webex/webex-core");
|
|
14
20
|
var _presenceBatcher = _interopRequireDefault(require("./presence-batcher"));
|
|
15
21
|
var _presenceWorker = _interopRequireDefault(require("./presence-worker"));
|
|
16
|
-
|
|
22
|
+
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; } /*!
|
|
17
24
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
18
25
|
*/
|
|
19
|
-
|
|
20
26
|
var defaultSubscriptionTtl = 600;
|
|
21
27
|
var USER = 'user';
|
|
22
28
|
var USER_PRESENCE_ENABLED = 'user-presence-enabled';
|
|
@@ -39,7 +45,7 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
39
45
|
}
|
|
40
46
|
},
|
|
41
47
|
/**
|
|
42
|
-
* Initialize the presence
|
|
48
|
+
* Initialize the presence plugin
|
|
43
49
|
* @returns {undefined}
|
|
44
50
|
*/
|
|
45
51
|
initialize: function initialize() {
|
|
@@ -50,6 +56,20 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
50
56
|
}
|
|
51
57
|
});
|
|
52
58
|
},
|
|
59
|
+
/**
|
|
60
|
+
* Initializes the presence worker.
|
|
61
|
+
* @returns {undefined}
|
|
62
|
+
*/
|
|
63
|
+
initializeWorker: function initializeWorker() {
|
|
64
|
+
var _this2 = this;
|
|
65
|
+
if (this.webex.ready) {
|
|
66
|
+
this.worker.initialize(this.webex);
|
|
67
|
+
} else {
|
|
68
|
+
this.webex.once('ready', function () {
|
|
69
|
+
_this2.worker.initialize(_this2.webex);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
},
|
|
53
73
|
/**
|
|
54
74
|
* Trigger an event.
|
|
55
75
|
* @param {string} event
|
|
@@ -132,12 +152,12 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
132
152
|
* @returns {Promise<PresenceStatusesObject>} resolves with an object with key of `statusList` array
|
|
133
153
|
*/
|
|
134
154
|
list: function list(personIds) {
|
|
135
|
-
var
|
|
155
|
+
var _this3 = this;
|
|
136
156
|
if (!personIds || !(0, _isArray.default)(personIds)) {
|
|
137
157
|
return _promise.default.reject(new Error('An array of person ids is required'));
|
|
138
158
|
}
|
|
139
159
|
return _promise.default.all(personIds.map(function (id) {
|
|
140
|
-
return
|
|
160
|
+
return _this3.batcher.request(id);
|
|
141
161
|
})).then(function (presences) {
|
|
142
162
|
return {
|
|
143
163
|
statusList: presences
|
|
@@ -152,7 +172,7 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
152
172
|
* @returns {Promise}
|
|
153
173
|
*/
|
|
154
174
|
subscribe: function subscribe(personIds) {
|
|
155
|
-
var
|
|
175
|
+
var _this4 = this;
|
|
156
176
|
var subscriptionTtl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultSubscriptionTtl;
|
|
157
177
|
var subjects;
|
|
158
178
|
var batches = [];
|
|
@@ -170,7 +190,7 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
170
190
|
batches.push(subjects.slice(i, i + batchLimit));
|
|
171
191
|
}
|
|
172
192
|
return _promise.default.all(batches.map(function (ids) {
|
|
173
|
-
return
|
|
193
|
+
return _this4.webex.request({
|
|
174
194
|
method: 'POST',
|
|
175
195
|
api: 'apheleia',
|
|
176
196
|
resource: 'subscriptions',
|
|
@@ -229,12 +249,14 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
229
249
|
method: 'POST',
|
|
230
250
|
api: 'apheleia',
|
|
231
251
|
resource: 'events',
|
|
232
|
-
body: {
|
|
252
|
+
body: _objectSpread(_objectSpread({
|
|
233
253
|
subject: this.webex.internal.device.userId,
|
|
234
|
-
eventType: status
|
|
235
|
-
|
|
254
|
+
eventType: status
|
|
255
|
+
}, status !== 'dnd' && {
|
|
256
|
+
label: this.webex.internal.device.userId
|
|
257
|
+
}), {}, {
|
|
236
258
|
ttl: ttl
|
|
237
|
-
}
|
|
259
|
+
})
|
|
238
260
|
}).then(function (response) {
|
|
239
261
|
return response.body;
|
|
240
262
|
});
|
|
@@ -255,7 +277,7 @@ var Presence = _webexCore.WebexPlugin.extend({
|
|
|
255
277
|
dequeue: function dequeue(id) {
|
|
256
278
|
return this.worker.dequeue(id);
|
|
257
279
|
},
|
|
258
|
-
version: "3.
|
|
280
|
+
version: "3.6.0"
|
|
259
281
|
});
|
|
260
282
|
var _default2 = exports.default = Presence;
|
|
261
283
|
//# sourceMappingURL=presence.js.map
|
package/dist/presence.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["require","_webexCore","_presenceBatcher","_interopRequireDefault","_presenceWorker","defaultSubscriptionTtl","USER","USER_PRESENCE_ENABLED","Presence","WebexPlugin","extend","namespace","children","batcher","PresenceBatcher","session","worker","default","_default","PresenceWorker","type","initialize","_this","webex","once","config","initializeWorker","emitEvent","event","payload","trigger","enable","internal","feature","setFeature","then","response","value","disable","isEnabled","getFeature","get","personId","_promise","reject","Error","request","method","service","resource","concat","body","list","personIds","_this2","_isArray","all","map","id","presences","statusList","subscribe","_this3","subscriptionTtl","arguments","length","undefined","subjects","batches","batchLimit","i","push","slice","ids","api","includeStatus","responses","idBatches","_ref","apply","_toConsumableArray2","unsubscribe","setStatus","status","ttl","subject","device","userId","eventType","label","enqueue","dequeue","version","_default2","exports"],"sources":["presence.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport '@webex/internal-plugin-device';\n\nimport {WebexPlugin} from '@webex/webex-core';\n\nimport PresenceBatcher from './presence-batcher';\nimport PresenceWorker from './presence-worker';\n\nconst defaultSubscriptionTtl = 600;\nconst USER = 'user';\nconst USER_PRESENCE_ENABLED = 'user-presence-enabled';\n\n/**\n * @class\n * @extends WebexPlugin\n */\nconst Presence = WebexPlugin.extend({\n namespace: 'Presence',\n\n children: {\n batcher: PresenceBatcher,\n },\n\n session: {\n worker: {\n default() {\n return new PresenceWorker();\n },\n type: 'any',\n },\n },\n\n /**\n * Initialize the presence worker for client\n * @returns {undefined}\n */\n initialize() {\n this.webex.once('ready', () => {\n if (this.config.initializeWorker) {\n this.worker.initialize(this.webex);\n }\n });\n },\n\n /**\n * Trigger an event.\n * @param {string} event\n * @param {string} payload\n * @returns {undefined}\n */\n emitEvent(event, payload) {\n if (payload.type && payload.payload) {\n this.trigger(event, payload);\n }\n },\n\n /**\n * Enables presence feature\n * @returns {Promise<boolean>} resolves with true, if successful\n */\n enable() {\n return this.webex.internal.feature\n .setFeature(USER, USER_PRESENCE_ENABLED, true)\n .then((response) => response.value);\n },\n\n /**\n * Disables presence feature\n * @returns {Promise<boolean>} resolves with false, if successful\n */\n disable() {\n return this.webex.internal.feature\n .setFeature(USER, USER_PRESENCE_ENABLED, false)\n .then((response) => response.value);\n },\n\n /**\n * Returns true if presence is enabled, false otherwise\n * @returns {Promise<boolean>} resolves with true if presence is enabled\n */\n isEnabled() {\n return this.webex.internal.feature.getFeature(USER, USER_PRESENCE_ENABLED);\n },\n\n /**\n * The status object\n * @typedef {Object} PresenceStatusObject\n * @property {string} url: Public resource identifier for presence\n * @property {string} subject: User ID for the user the returned composed presence represents\n * @property {string} status: Current composed presence state\n * @property {string} statusTime: DateTime in RFC3339 format that the current status began\n * @property {string} lastActive: DateTime in RFC3339 format that the service last saw activity from the user.\n * @property {string} expires: DEPRECATED - DateTime in RFC3339 format that represents when the current\n * status will expire. Will not exist if expiresTTL is -1.\n * @property {Number} expiresTTL: TTL in seconds until the status will expire. If TTL is -1 the current\n * status has no known expiration.\n * @property {string} expiresTime: DateTime in RFC3339 format that the current status will expire. Missing\n * field means no known expiration.\n * @property {Object} vectorCounters: Used for packet ordering and tracking.\n * @property {Boolean} suppressNotifications: Indicates if notification suppression is recommended for this status.\n * @property {string} lastSeenDeviceUrl: Resource Identifier of the last device to post presence activity for\n * this user.\n */\n\n /**\n * Gets the current presence status of a given person id\n * @param {string} personId\n * @returns {Promise<PresenceStatusObject>} resolves with status object of person\n */\n get(personId) {\n if (!personId) {\n return Promise.reject(new Error('A person id is required'));\n }\n\n return this.webex\n .request({\n method: 'GET',\n service: 'apheleia',\n resource: `compositions?userId=${personId}`,\n })\n .then((response) => response.body);\n },\n\n /**\n * @typedef {Object} PresenceStatusesObject\n * @property {Array.<PresenceStatusObject>} statusList\n */\n /**\n * Gets the current presence statuses of an array of people ids\n * @param {Array} personIds\n * @returns {Promise<PresenceStatusesObject>} resolves with an object with key of `statusList` array\n */\n list(personIds) {\n if (!personIds || !Array.isArray(personIds)) {\n return Promise.reject(new Error('An array of person ids is required'));\n }\n\n return Promise.all(personIds.map((id) => this.batcher.request(id))).then((presences) => ({\n statusList: presences,\n }));\n },\n\n /**\n * Subscribes to a person's presence status updates\n * Updates are sent via mercury events `apheleia.subscription_update`\n * @param {string | Array} personIds\n * @param {number} subscriptionTtl - Requested length of subscriptions in seconds.\n * @returns {Promise}\n */\n subscribe(personIds, subscriptionTtl = defaultSubscriptionTtl) {\n let subjects;\n const batches = [];\n const batchLimit = 50;\n\n if (!personIds) {\n return Promise.reject(new Error('A person id is required'));\n }\n if (Array.isArray(personIds)) {\n subjects = personIds;\n } else {\n subjects = [personIds];\n }\n // Limit batches to 50 ids per request\n for (let i = 0; i < subjects.length; i += batchLimit) {\n batches.push(subjects.slice(i, i + batchLimit));\n }\n\n return Promise.all(\n batches.map((ids) =>\n this.webex\n .request({\n method: 'POST',\n api: 'apheleia',\n resource: 'subscriptions',\n body: {\n subjects: ids,\n subscriptionTtl,\n includeStatus: true,\n },\n })\n .then((response) => response.body.responses)\n )\n ).then((idBatches) => ({responses: [].concat(...idBatches)}));\n },\n\n /**\n * Unsubscribes from a person or group of people's presence subscription\n * @param {string | Array} personIds\n * @returns {Promise}\n */\n unsubscribe(personIds) {\n let subjects;\n\n if (!personIds) {\n return Promise.reject(new Error('A person id is required'));\n }\n if (Array.isArray(personIds)) {\n subjects = personIds;\n } else {\n subjects = [personIds];\n }\n\n return this.webex.request({\n method: 'POST',\n api: 'apheleia',\n resource: 'subscriptions',\n body: {\n subjects,\n subscriptionTtl: 0,\n includeStatus: true,\n },\n });\n },\n\n /**\n * Sets the status of the current user\n * @param {string} status - active | inactive | ooo | dnd\n * @param {number} ttl - Time To Live for the event in seconds.\n * @returns {Promise}\n */\n setStatus(status, ttl) {\n if (!status) {\n return Promise.reject(new Error('A status is required'));\n }\n\n return this.webex\n .request({\n method: 'POST',\n api: 'apheleia',\n resource: 'events',\n body: {\n subject: this.webex.internal.device.userId,\n eventType: status,\n label: this.webex.internal.device.userId,\n ttl,\n },\n })\n .then((response) => response.body);\n },\n\n /**\n * Retrieves and subscribes to a user's presence.\n * @param {string} id\n * @returns {undefined}\n */\n enqueue(id) {\n return this.worker.enqueue(id);\n },\n\n /**\n * Retract from subscribing to a user's presence.\n * @param {string} id\n * @returns {undefined}\n */\n dequeue(id) {\n return this.worker.dequeue(id);\n },\n});\n\nexport default Presence;\n"],"mappings":";;;;;;;;;;;AAIAA,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,eAAA,GAAAD,sBAAA,CAAAH,OAAA;AATA;AACA;AACA;;AASA,IAAMK,sBAAsB,GAAG,GAAG;AAClC,IAAMC,IAAI,GAAG,MAAM;AACnB,IAAMC,qBAAqB,GAAG,uBAAuB;;AAErD;AACA;AACA;AACA;AACA,IAAMC,QAAQ,GAAGC,sBAAW,CAACC,MAAM,CAAC;EAClCC,SAAS,EAAE,U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Q;MAClBE,IAAI,EAAE;QACJkC,OAAO,EAAE,IAAI,CAAC9D,KAAK,CAACS,QAAQ,CAACsD,MAAM,CAACC,MAAM;QAC1CC,SAAS,EAAEL,MAAM;QACjBM,KAAK,EAAE,IAAI,CAAClE,KAAK,CAACS,QAAQ,CAACsD,MAAM,CAACC,MAAM;QACxCH,GAAG,EAAHA;MACF;IACF,CAAC,CAAC,CACDjD,IAAI,CAAC,UAACC,QAAQ;MAAA,OAAKA,QAAQ,CAACe,IAAI;IAAA,EAAC;EACtC,CAAC;EAED;AACF;AACA;AACA;AACA;EACEuC,OAAO,WAAAA,QAAChC,EAAE,EAAE;IACV,OAAO,IAAI,CAAC1C,MAAM,CAAC0E,OAAO,CAAChC,EAAE,CAAC;EAChC,CAAC;EAED;AACF;AACA;AACA;AACA;EACEiC,OAAO,WAAAA,QAACjC,EAAE,EAAE;IACV,OAAO,IAAI,CAAC1C,MAAM,CAAC2E,OAAO,CAACjC,EAAE,CAAC;EAChC,CAAC;EAAAkC,OAAA;AACH,CAAC,CAAC;AAAC,IAAAC,SAAA,GAAAC,OAAA,CAAA7E,OAAA,GAEYT,QAAQ"}
|
|
1
|
+
{"version":3,"names":["require","_webexCore","_presenceBatcher","_interopRequireDefault","_presenceWorker","ownKeys","e","r","t","_Object$keys","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","defaultSubscriptionTtl","USER","USER_PRESENCE_ENABLED","Presence","WebexPlugin","extend","namespace","children","batcher","PresenceBatcher","session","worker","_default","PresenceWorker","type","initialize","_this","webex","once","config","initializeWorker","_this2","ready","emitEvent","event","payload","trigger","enable","internal","feature","setFeature","then","response","value","disable","isEnabled","getFeature","get","personId","_promise","reject","Error","request","method","service","resource","concat","body","list","personIds","_this3","_isArray","all","map","id","presences","statusList","subscribe","_this4","subscriptionTtl","undefined","subjects","batches","batchLimit","i","slice","ids","api","includeStatus","responses","idBatches","_ref","_toConsumableArray2","unsubscribe","setStatus","status","ttl","subject","device","userId","eventType","label","enqueue","dequeue","version","_default2","exports"],"sources":["presence.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport '@webex/internal-plugin-device';\n\nimport {WebexPlugin} from '@webex/webex-core';\n\nimport PresenceBatcher from './presence-batcher';\nimport PresenceWorker from './presence-worker';\n\nconst defaultSubscriptionTtl = 600;\nconst USER = 'user';\nconst USER_PRESENCE_ENABLED = 'user-presence-enabled';\n\n/**\n * @class\n * @extends WebexPlugin\n */\nconst Presence = WebexPlugin.extend({\n namespace: 'Presence',\n\n children: {\n batcher: PresenceBatcher,\n },\n\n session: {\n worker: {\n default() {\n return new PresenceWorker();\n },\n type: 'any',\n },\n },\n\n /**\n * Initialize the presence plugin\n * @returns {undefined}\n */\n initialize() {\n this.webex.once('ready', () => {\n if (this.config.initializeWorker) {\n this.worker.initialize(this.webex);\n }\n });\n },\n\n /**\n * Initializes the presence worker.\n * @returns {undefined}\n */\n initializeWorker() {\n if (this.webex.ready) {\n this.worker.initialize(this.webex);\n } else {\n this.webex.once('ready', () => {\n this.worker.initialize(this.webex);\n });\n }\n },\n\n /**\n * Trigger an event.\n * @param {string} event\n * @param {string} payload\n * @returns {undefined}\n */\n emitEvent(event, payload) {\n if (payload.type && payload.payload) {\n this.trigger(event, payload);\n }\n },\n\n /**\n * Enables presence feature\n * @returns {Promise<boolean>} resolves with true, if successful\n */\n enable() {\n return this.webex.internal.feature\n .setFeature(USER, USER_PRESENCE_ENABLED, true)\n .then((response) => response.value);\n },\n\n /**\n * Disables presence feature\n * @returns {Promise<boolean>} resolves with false, if successful\n */\n disable() {\n return this.webex.internal.feature\n .setFeature(USER, USER_PRESENCE_ENABLED, false)\n .then((response) => response.value);\n },\n\n /**\n * Returns true if presence is enabled, false otherwise\n * @returns {Promise<boolean>} resolves with true if presence is enabled\n */\n isEnabled() {\n return this.webex.internal.feature.getFeature(USER, USER_PRESENCE_ENABLED);\n },\n\n /**\n * The status object\n * @typedef {Object} PresenceStatusObject\n * @property {string} url: Public resource identifier for presence\n * @property {string} subject: User ID for the user the returned composed presence represents\n * @property {string} status: Current composed presence state\n * @property {string} statusTime: DateTime in RFC3339 format that the current status began\n * @property {string} lastActive: DateTime in RFC3339 format that the service last saw activity from the user.\n * @property {string} expires: DEPRECATED - DateTime in RFC3339 format that represents when the current\n * status will expire. Will not exist if expiresTTL is -1.\n * @property {Number} expiresTTL: TTL in seconds until the status will expire. If TTL is -1 the current\n * status has no known expiration.\n * @property {string} expiresTime: DateTime in RFC3339 format that the current status will expire. Missing\n * field means no known expiration.\n * @property {Object} vectorCounters: Used for packet ordering and tracking.\n * @property {Boolean} suppressNotifications: Indicates if notification suppression is recommended for this status.\n * @property {string} lastSeenDeviceUrl: Resource Identifier of the last device to post presence activity for\n * this user.\n */\n\n /**\n * Gets the current presence status of a given person id\n * @param {string} personId\n * @returns {Promise<PresenceStatusObject>} resolves with status object of person\n */\n get(personId) {\n if (!personId) {\n return Promise.reject(new Error('A person id is required'));\n }\n\n return this.webex\n .request({\n method: 'GET',\n service: 'apheleia',\n resource: `compositions?userId=${personId}`,\n })\n .then((response) => response.body);\n },\n\n /**\n * @typedef {Object} PresenceStatusesObject\n * @property {Array.<PresenceStatusObject>} statusList\n */\n /**\n * Gets the current presence statuses of an array of people ids\n * @param {Array} personIds\n * @returns {Promise<PresenceStatusesObject>} resolves with an object with key of `statusList` array\n */\n list(personIds) {\n if (!personIds || !Array.isArray(personIds)) {\n return Promise.reject(new Error('An array of person ids is required'));\n }\n\n return Promise.all(personIds.map((id) => this.batcher.request(id))).then((presences) => ({\n statusList: presences,\n }));\n },\n\n /**\n * Subscribes to a person's presence status updates\n * Updates are sent via mercury events `apheleia.subscription_update`\n * @param {string | Array} personIds\n * @param {number} subscriptionTtl - Requested length of subscriptions in seconds.\n * @returns {Promise}\n */\n subscribe(personIds, subscriptionTtl = defaultSubscriptionTtl) {\n let subjects;\n const batches = [];\n const batchLimit = 50;\n\n if (!personIds) {\n return Promise.reject(new Error('A person id is required'));\n }\n if (Array.isArray(personIds)) {\n subjects = personIds;\n } else {\n subjects = [personIds];\n }\n // Limit batches to 50 ids per request\n for (let i = 0; i < subjects.length; i += batchLimit) {\n batches.push(subjects.slice(i, i + batchLimit));\n }\n\n return Promise.all(\n batches.map((ids) =>\n this.webex\n .request({\n method: 'POST',\n api: 'apheleia',\n resource: 'subscriptions',\n body: {\n subjects: ids,\n subscriptionTtl,\n includeStatus: true,\n },\n })\n .then((response) => response.body.responses)\n )\n ).then((idBatches) => ({responses: [].concat(...idBatches)}));\n },\n\n /**\n * Unsubscribes from a person or group of people's presence subscription\n * @param {string | Array} personIds\n * @returns {Promise}\n */\n unsubscribe(personIds) {\n let subjects;\n\n if (!personIds) {\n return Promise.reject(new Error('A person id is required'));\n }\n if (Array.isArray(personIds)) {\n subjects = personIds;\n } else {\n subjects = [personIds];\n }\n\n return this.webex.request({\n method: 'POST',\n api: 'apheleia',\n resource: 'subscriptions',\n body: {\n subjects,\n subscriptionTtl: 0,\n includeStatus: true,\n },\n });\n },\n\n /**\n * Sets the status of the current user\n * @param {string} status - active | inactive | ooo | dnd\n * @param {number} ttl - Time To Live for the event in seconds.\n * @returns {Promise}\n */\n setStatus(status, ttl) {\n if (!status) {\n return Promise.reject(new Error('A status is required'));\n }\n\n return this.webex\n .request({\n method: 'POST',\n api: 'apheleia',\n resource: 'events',\n body: {\n subject: this.webex.internal.device.userId,\n eventType: status,\n ...(status !== 'dnd' && {label: this.webex.internal.device.userId}),\n ttl,\n },\n })\n .then((response) => response.body);\n },\n\n /**\n * Retrieves and subscribes to a user's presence.\n * @param {string} id\n * @returns {undefined}\n */\n enqueue(id) {\n return this.worker.enqueue(id);\n },\n\n /**\n * Retract from subscribing to a user's presence.\n * @param {string} id\n * @returns {undefined}\n */\n dequeue(id) {\n return this.worker.dequeue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GED
|
@@ -24,22 +24,22 @@
|
|
|
24
24
|
"@webex/eslint-config-legacy": "0.0.0",
|
|
25
25
|
"@webex/jest-config-legacy": "0.0.0",
|
|
26
26
|
"@webex/legacy-tools": "0.0.0",
|
|
27
|
-
"@webex/test-helper-chai": "3.
|
|
28
|
-
"@webex/test-helper-mocha": "3.
|
|
29
|
-
"@webex/test-helper-mock-webex": "3.
|
|
30
|
-
"@webex/test-helper-test-users": "3.
|
|
27
|
+
"@webex/test-helper-chai": "3.6.0",
|
|
28
|
+
"@webex/test-helper-mocha": "3.6.0",
|
|
29
|
+
"@webex/test-helper-mock-webex": "3.6.0",
|
|
30
|
+
"@webex/test-helper-test-users": "3.6.0",
|
|
31
31
|
"eslint": "^8.24.0",
|
|
32
32
|
"prettier": "^2.7.1",
|
|
33
33
|
"sinon": "^9.2.4"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@webex/internal-plugin-device": "3.
|
|
37
|
-
"@webex/internal-plugin-mercury": "3.
|
|
38
|
-
"@webex/test-helper-chai": "3.
|
|
39
|
-
"@webex/test-helper-mocha": "3.
|
|
40
|
-
"@webex/test-helper-mock-webex": "3.
|
|
41
|
-
"@webex/test-helper-test-users": "3.
|
|
42
|
-
"@webex/webex-core": "3.
|
|
36
|
+
"@webex/internal-plugin-device": "3.6.0",
|
|
37
|
+
"@webex/internal-plugin-mercury": "3.6.0",
|
|
38
|
+
"@webex/test-helper-chai": "3.6.0",
|
|
39
|
+
"@webex/test-helper-mocha": "3.6.0",
|
|
40
|
+
"@webex/test-helper-mock-webex": "3.6.0",
|
|
41
|
+
"@webex/test-helper-test-users": "3.6.0",
|
|
42
|
+
"@webex/webex-core": "3.6.0",
|
|
43
43
|
"lodash": "^4.17.21"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"test:style": "eslint ./src/**/*.*",
|
|
52
52
|
"test:unit": "webex-legacy-tools test --unit --runner jest"
|
|
53
53
|
},
|
|
54
|
-
"version": "3.
|
|
54
|
+
"version": "3.6.0"
|
|
55
55
|
}
|
package/src/presence.js
CHANGED
|
@@ -34,7 +34,7 @@ const Presence = WebexPlugin.extend({
|
|
|
34
34
|
},
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* Initialize the presence
|
|
37
|
+
* Initialize the presence plugin
|
|
38
38
|
* @returns {undefined}
|
|
39
39
|
*/
|
|
40
40
|
initialize() {
|
|
@@ -45,6 +45,20 @@ const Presence = WebexPlugin.extend({
|
|
|
45
45
|
});
|
|
46
46
|
},
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Initializes the presence worker.
|
|
50
|
+
* @returns {undefined}
|
|
51
|
+
*/
|
|
52
|
+
initializeWorker() {
|
|
53
|
+
if (this.webex.ready) {
|
|
54
|
+
this.worker.initialize(this.webex);
|
|
55
|
+
} else {
|
|
56
|
+
this.webex.once('ready', () => {
|
|
57
|
+
this.worker.initialize(this.webex);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
|
|
48
62
|
/**
|
|
49
63
|
* Trigger an event.
|
|
50
64
|
* @param {string} event
|
|
@@ -234,7 +248,7 @@ const Presence = WebexPlugin.extend({
|
|
|
234
248
|
body: {
|
|
235
249
|
subject: this.webex.internal.device.userId,
|
|
236
250
|
eventType: status,
|
|
237
|
-
label: this.webex.internal.device.userId,
|
|
251
|
+
...(status !== 'dnd' && {label: this.webex.internal.device.userId}),
|
|
238
252
|
ttl,
|
|
239
253
|
},
|
|
240
254
|
})
|
|
@@ -79,7 +79,7 @@ describe.skip('plugin-presence', () => {
|
|
|
79
79
|
};
|
|
80
80
|
sinon.spy(webex, 'request');
|
|
81
81
|
|
|
82
|
-
webex.internal.presence.setStatus('
|
|
82
|
+
webex.internal.presence.setStatus('active');
|
|
83
83
|
|
|
84
84
|
assert.calledOnce(webex.request);
|
|
85
85
|
|
|
@@ -87,6 +87,44 @@ describe.skip('plugin-presence', () => {
|
|
|
87
87
|
|
|
88
88
|
assert.equal(request.args[0].body.label, testGuid);
|
|
89
89
|
});
|
|
90
|
+
|
|
91
|
+
it('does not pass a label to the API if the status is DND', () => {
|
|
92
|
+
const testGuid = 'test-guid';
|
|
93
|
+
|
|
94
|
+
webex.internal.device.userId = testGuid;
|
|
95
|
+
|
|
96
|
+
webex.request = function (options) {
|
|
97
|
+
return Promise.resolve({
|
|
98
|
+
statusCode: 204,
|
|
99
|
+
body: [],
|
|
100
|
+
options,
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
sinon.spy(webex, 'request');
|
|
104
|
+
|
|
105
|
+
webex.internal.presence.setStatus('dnd');
|
|
106
|
+
|
|
107
|
+
assert.calledOnce(webex.request);
|
|
108
|
+
|
|
109
|
+
const request = webex.request.getCall(0);
|
|
110
|
+
|
|
111
|
+
assert.notProperty(request.args[0].body, 'label');
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe('#initializeWorker()', () => {
|
|
116
|
+
it('initializes the worker once webex is ready', () => {
|
|
117
|
+
webex.internal.presence.worker = {initialize: sinon.spy()};
|
|
118
|
+
webex.presence.config.initializeWorker = false;
|
|
119
|
+
|
|
120
|
+
webex.internal.presence.initializeWorker();
|
|
121
|
+
|
|
122
|
+
assert.notCalled(webex.internal.presence.worker.initialize);
|
|
123
|
+
|
|
124
|
+
webex.trigger('ready');
|
|
125
|
+
|
|
126
|
+
assert.calledOnce(webex.internal.presence.worker.initialize);
|
|
127
|
+
});
|
|
90
128
|
});
|
|
91
129
|
});
|
|
92
130
|
});
|