@webex/internal-plugin-conversation 3.7.0 → 3.8.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/conversation.js +187 -167
- package/dist/conversation.js.map +1 -1
- package/dist/share-activity.js +1 -1
- package/package.json +14 -14
- package/src/conversation.js +39 -34
- package/test/unit/spec/conversation.js +54 -43
package/dist/share-activity.js
CHANGED
package/package.json
CHANGED
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
]
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@webex/common": "3.
|
|
23
|
-
"@webex/helper-html": "3.
|
|
24
|
-
"@webex/helper-image": "3.
|
|
25
|
-
"@webex/internal-plugin-encryption": "3.
|
|
26
|
-
"@webex/internal-plugin-user": "3.
|
|
27
|
-
"@webex/webex-core": "3.
|
|
22
|
+
"@webex/common": "3.8.0",
|
|
23
|
+
"@webex/helper-html": "3.8.0",
|
|
24
|
+
"@webex/helper-image": "3.8.0",
|
|
25
|
+
"@webex/internal-plugin-encryption": "3.8.0",
|
|
26
|
+
"@webex/internal-plugin-user": "3.8.0",
|
|
27
|
+
"@webex/webex-core": "3.8.0",
|
|
28
28
|
"crypto-js": "^4.1.1",
|
|
29
29
|
"lodash": "^4.17.21",
|
|
30
30
|
"node-scr": "^0.3.0",
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"@webex/eslint-config-legacy": "0.0.0",
|
|
37
37
|
"@webex/jest-config-legacy": "0.0.0",
|
|
38
38
|
"@webex/legacy-tools": "0.0.0",
|
|
39
|
-
"@webex/test-helper-chai": "3.
|
|
40
|
-
"@webex/test-helper-file": "3.
|
|
41
|
-
"@webex/test-helper-make-local-url": "3.
|
|
42
|
-
"@webex/test-helper-mocha": "3.
|
|
43
|
-
"@webex/test-helper-mock-webex": "3.
|
|
44
|
-
"@webex/test-helper-retry": "3.
|
|
45
|
-
"@webex/test-helper-test-users": "3.
|
|
39
|
+
"@webex/test-helper-chai": "3.8.0",
|
|
40
|
+
"@webex/test-helper-file": "3.8.0",
|
|
41
|
+
"@webex/test-helper-make-local-url": "3.8.0",
|
|
42
|
+
"@webex/test-helper-mocha": "3.8.0",
|
|
43
|
+
"@webex/test-helper-mock-webex": "3.8.0",
|
|
44
|
+
"@webex/test-helper-retry": "3.8.0",
|
|
45
|
+
"@webex/test-helper-test-users": "3.8.0",
|
|
46
46
|
"eslint": "^8.24.0",
|
|
47
47
|
"prettier": "^2.7.1",
|
|
48
48
|
"sinon": "^9.2.4"
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"test:style": "eslint ./src/**/*.*",
|
|
57
57
|
"test:unit": "webex-legacy-tools test --unit --runner jest"
|
|
58
58
|
},
|
|
59
|
-
"version": "3.
|
|
59
|
+
"version": "3.8.0"
|
|
60
60
|
}
|
package/src/conversation.js
CHANGED
|
@@ -303,15 +303,16 @@ const Conversation = WebexPlugin.extend({
|
|
|
303
303
|
},
|
|
304
304
|
|
|
305
305
|
/**
|
|
306
|
-
*
|
|
307
|
-
* @param {Object} conversation
|
|
308
|
-
* @param {Object} reactionId
|
|
309
|
-
* @param {
|
|
306
|
+
* create a reaction
|
|
307
|
+
* @param {Object} conversation the conversation in which the reaction will be added
|
|
308
|
+
* @param {Object} reactionId reaction activity to be deleted
|
|
309
|
+
* @param {Object} actorId id of person object who is reacting
|
|
310
|
+
* @param {String} recipientId used when reacting to direct IMC messages
|
|
310
311
|
* @returns {Promise<Activity>}
|
|
311
312
|
*/
|
|
312
|
-
deleteReaction(conversation, reactionId, recipientId) {
|
|
313
|
+
deleteReaction(conversation, reactionId, actorId, recipientId) {
|
|
313
314
|
const deleteReactionPayload = {
|
|
314
|
-
actor: {objectType: 'person', id: this.webex.internal.device.userId},
|
|
315
|
+
actor: {objectType: 'person', id: actorId ?? this.webex.internal.device.userId},
|
|
315
316
|
object: {
|
|
316
317
|
id: reactionId,
|
|
317
318
|
objectType: 'activity',
|
|
@@ -334,39 +335,43 @@ const Conversation = WebexPlugin.extend({
|
|
|
334
335
|
|
|
335
336
|
/**
|
|
336
337
|
* create a reaction
|
|
337
|
-
* @param {Object} conversation
|
|
338
|
+
* @param {Object} conversation the conversation in which the reaction will be added
|
|
338
339
|
* @param {Object} displayName must be 'celebrate', 'heart', 'thumbsup', 'smiley', 'haha', 'confused', 'sad'
|
|
339
|
-
* @param {Object}
|
|
340
|
-
* @param {
|
|
340
|
+
* @param {Object} parentActivity activity object from that we are reacting to
|
|
341
|
+
* @param {Object} actorId id of person object who is reacting
|
|
342
|
+
* @param {String} recipientId used when reacting to direct IMC messages
|
|
341
343
|
* @returns {Promise<Activity>}
|
|
342
344
|
*/
|
|
343
|
-
addReaction(conversation, displayName,
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
id: conversation.id,
|
|
349
|
-
objectType: 'conversation',
|
|
350
|
-
},
|
|
351
|
-
verb: 'add',
|
|
352
|
-
objectType: 'activity',
|
|
353
|
-
parent: {
|
|
354
|
-
type: 'reaction',
|
|
355
|
-
id: activity.id,
|
|
356
|
-
},
|
|
357
|
-
object: {
|
|
358
|
-
objectType: 'reaction2',
|
|
359
|
-
displayName,
|
|
360
|
-
hmac,
|
|
361
|
-
},
|
|
362
|
-
};
|
|
345
|
+
async addReaction(conversation, displayName, parentActivity, actorId, recipientId) {
|
|
346
|
+
let hmac;
|
|
347
|
+
if (this.config.includeEncryptionTransforms) {
|
|
348
|
+
hmac = await this.createReactionHmac(displayName, parentActivity);
|
|
349
|
+
}
|
|
363
350
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
351
|
+
const addReactionPayload = {
|
|
352
|
+
actor: {objectType: 'person', id: actorId ?? this.webex.internal.device.userId},
|
|
353
|
+
target: {
|
|
354
|
+
id: conversation.id,
|
|
355
|
+
objectType: 'conversation',
|
|
356
|
+
},
|
|
357
|
+
verb: 'add',
|
|
358
|
+
objectType: 'activity',
|
|
359
|
+
parent: {
|
|
360
|
+
type: 'reaction',
|
|
361
|
+
id: parentActivity.id,
|
|
362
|
+
},
|
|
363
|
+
object: {
|
|
364
|
+
objectType: 'reaction2',
|
|
365
|
+
displayName,
|
|
366
|
+
hmac,
|
|
367
|
+
},
|
|
368
|
+
};
|
|
367
369
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
+
if (recipientId) {
|
|
371
|
+
addReactionPayload.recipients = {items: [{id: recipientId, objectType: 'person'}]};
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
return this.sendReaction(conversation, addReactionPayload);
|
|
370
375
|
},
|
|
371
376
|
|
|
372
377
|
/**
|
|
@@ -37,67 +37,78 @@ describe('plugin-conversation', () => {
|
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
describe('addReaction()', () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
let conversation;
|
|
41
|
+
let recipientId;
|
|
42
|
+
let expectedRecipients;
|
|
43
|
+
let actorId;
|
|
44
|
+
|
|
45
|
+
beforeEach(() => {
|
|
46
|
+
conversation = webex.internal.conversation;
|
|
47
|
+
recipientId = 'example-recipient-id';
|
|
48
|
+
actorId = 'actorId-123';
|
|
49
|
+
expectedRecipients = {items: [{id: recipientId, objectType: 'person'}]};
|
|
44
50
|
conversation.sendReaction = sinon.stub().returns(Promise.resolve());
|
|
45
51
|
conversation.createReactionHmac = sinon.stub().returns(Promise.resolve('hmac'));
|
|
52
|
+
});
|
|
53
|
+
it('should add recipients to the payload if provided', async () => {
|
|
54
|
+
conversation.config.includeEncryptionTransforms = true;
|
|
46
55
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
56
|
+
await conversation.addReaction({}, 'example-display-name', {}, actorId, recipientId);
|
|
57
|
+
assert.called(conversation.createReactionHmac);
|
|
58
|
+
assert.deepEqual(conversation.sendReaction.args[0][1].recipients, expectedRecipients);
|
|
50
59
|
});
|
|
51
|
-
});
|
|
52
60
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const {conversation} = webex.internal;
|
|
56
|
-
const recipientId = 'example-recipient-id';
|
|
57
|
-
const expected = {items: [{id: recipientId, objectType: 'person'}]};
|
|
58
|
-
conversation.sendReaction = sinon.stub().returns(Promise.resolve());
|
|
61
|
+
it('will not call createReactionHmac if config prohibits', async () => {
|
|
62
|
+
conversation.config.includeEncryptionTransforms = false;
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
await conversation.addReaction({}, 'example-display-name', {}, actorId, recipientId);
|
|
65
|
+
assert.deepEqual(conversation.sendReaction.args[0][1].recipients, expectedRecipients);
|
|
66
|
+
assert.notCalled(conversation.createReactionHmac);
|
|
63
67
|
});
|
|
64
|
-
});
|
|
65
68
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
it('should use actorId if provided', async () => {
|
|
70
|
+
await conversation.addReaction({}, 'example-display-name', {}, actorId, recipientId);
|
|
71
|
+
assert.equal(conversation.sendReaction.args[0][1].actor.id, actorId);
|
|
72
|
+
});
|
|
70
73
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
it('should use fallback device.userId if no actorId provided', async () => {
|
|
75
|
+
const defaultUserId = 'fallback-id';
|
|
76
|
+
webex.internal.device.userId = defaultUserId;
|
|
77
|
+
await conversation.addReaction({}, 'example-display-name', {}, undefined, recipientId);
|
|
78
|
+
assert.equal(conversation.sendReaction.args[0][1].actor.id, defaultUserId);
|
|
74
79
|
});
|
|
75
80
|
});
|
|
76
81
|
|
|
77
|
-
describe('
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
describe('deleteReaction()', () => {
|
|
83
|
+
let conversation;
|
|
84
|
+
let recipientId;
|
|
85
|
+
let expectedRecipients;
|
|
86
|
+
let actorId;
|
|
87
|
+
|
|
88
|
+
beforeEach(() => {
|
|
89
|
+
conversation = webex.internal.conversation;
|
|
90
|
+
recipientId = 'example-recipient-id';
|
|
91
|
+
actorId = 'actorId-123';
|
|
92
|
+
expectedRecipients = {items: [{id: recipientId, objectType: 'person'}]};
|
|
82
93
|
conversation.sendReaction = sinon.stub().returns(Promise.resolve());
|
|
83
94
|
conversation.createReactionHmac = sinon.stub().returns(Promise.resolve('hmac'));
|
|
95
|
+
});
|
|
84
96
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
97
|
+
it('should add recipients to the payload if provided', async () => {
|
|
98
|
+
await conversation.deleteReaction({}, 'example-reaction-id', actorId, recipientId);
|
|
99
|
+
assert.deepEqual(conversation.sendReaction.args[0][1].recipients, expectedRecipients);
|
|
88
100
|
});
|
|
89
|
-
});
|
|
90
101
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const expected = {items: [{id: recipientId, objectType: 'person'}]};
|
|
96
|
-
conversation.sendReaction = sinon.stub().returns(Promise.resolve());
|
|
102
|
+
it('should use actorId if provided', async () => {
|
|
103
|
+
await conversation.deleteReaction({}, 'example-reaction-id', actorId, recipientId);
|
|
104
|
+
assert.equal(conversation.sendReaction.args[0][1].actor.id, actorId);
|
|
105
|
+
});
|
|
97
106
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
107
|
+
it('should use fallback device.userId if no actorId provided', async () => {
|
|
108
|
+
const defaultUserId = 'fallback-id';
|
|
109
|
+
webex.internal.device.userId = defaultUserId;
|
|
110
|
+
await conversation.deleteReaction({}, 'example-reaction-id', undefined, recipientId);
|
|
111
|
+
assert.equal(conversation.sendReaction.args[0][1].actor.id, defaultUserId);
|
|
101
112
|
});
|
|
102
113
|
});
|
|
103
114
|
|