Skip to content

Commit

Permalink
feat(conversation): slight refactor conversation payload transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
rstachof committed Nov 14, 2024
1 parent 0b33840 commit d420089
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
14 changes: 4 additions & 10 deletions packages/@webex/internal-plugin-conversation/src/conversation.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,13 @@ const Conversation = WebexPlugin.extend({
namespace: 'Conversation',
initialize() {
this.listenToOnce(this.webex, 'ready', () => {
this.addEncryptionDecryptionTransforms();
this.webex.config.payloadTransformer.transforms =
this.webex.config.payloadTransformer.transforms
.concat(this.config.includeDecryptionTransforms ? decryptionTransforms : [])
.concat(this.config.includeEncryptionTransforms ? encryptionTransforms : []);
});
},

addEncryptionDecryptionTransforms() {
this.logger.error('@@@:this.config', this.config);
this.webex.logger.error('@@@:this.config', this.config);
this.webex.config.payloadTransformer.transforms =
this.webex.config.payloadTransformer.transforms
.concat(this.config.includeDecryptionTransforms ? decryptionTransforms : [])
.concat(this.config.includeEncryptionTransforms ? encryptionTransforms : []);
},

/**
* @param {String} cluster the cluster containing the id
* @param {UUID} [id] the id of the conversation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,6 @@ describe('plugin-conversation', () => {
webex.internal.services.getServiceUrlFromClusterId = sinon.stub().returns(convoUrl);
});

describe('#initialize', () => {
it('adds relevant handlers when webex is ready', () => {
const addEncryptionDecryptionTransformsStub = sinon.stub(
webex.internal.conversation,
'addEncryptionDecryptionTransforms'
);

assert.notCalled(addEncryptionDecryptionTransformsStub);

// Initialize should have already run, so there should be an event handler already
webex.trigger('ready');

assert.calledOnce(addEncryptionDecryptionTransformsStub);
assert.calledWith(addEncryptionDecryptionTransformsStub);
});
});

describe('addReaction()', () => {
it('should add recipients to the payload if provided', () => {
const {conversation} = webex.internal;
Expand Down

0 comments on commit d420089

Please sign in to comment.