-
Notifications
You must be signed in to change notification settings - Fork 380
feat(internal-plugin-task): support task management #4453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
import WebexCore from '@webex/webex-core'; | ||
|
||
const webex = new WebexCore(); | ||
webex.internal.task.WHATEVER; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add more info on the usage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I will add more usage to README.
@@ -0,0 +1 @@ | |||
module.exports = {browser: true}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why would we need this , it should also be able to run on node env , i see lot of use cases for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just followed other internal plugin's way to introduce this file, I am not sure if there are any potential issues if missing it.
@@ -0,0 +1,50 @@ | |||
const _decryptTextProp = (ctx, name, key, object) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the mercury already decrypts text you dont need this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am not sure about that @arun3528 . i think each plugin still needs to manage decrypting mercury events
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arun3528 It is not for mercury event, it is for decrypting API response.
@@ -0,0 +1,45 @@ | |||
import {isArray} from 'lodash'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets check on this as well , i think the SDk also does encrypt the text check how the conversaion plugin is setup , that would help
its all done via intercepters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arun3528 the decrypt/encrypt flow in the SDK plugins is pretty convoluted and pretty unfriendly to dev. different plugins seem to have adapted other ways of doing it. this task plugin seems to be heavily copying calendar plugin (see: packages/@webex/internal-plugin-calendar/src/calendar.decrypt.helper.js). also ai-assistant plugin did decryption different and just called await this.webex.internal.encryption.decryptText(encryptionKeyUrl, value)
wherever it was needed rather than the payload transformer flow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
registerInternalPlugin('task', Task, { | ||
config, | ||
payloadTransformer: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is where the logic for encryption and decryption will go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ever meet a issue before, the encrypt/decrypt rules configured in one plugin's payloadTransformer will affect another plugin, or conflict with each other, there is a example:
{
name: 'transformMeetingParticipants',
direction: 'inbound',
test(ctx, response) {
return Promise.resolve(
has(response, 'body.encryptedParticipants') &&
!(
response.options &&
response.options.service === 'calendar' &&
response.options.method === 'GET' &&
response.options.resource === 'schedulerData'
)
);
},
We have to add such codes to resolve conflict.
// operation. | ||
this.listenToOnce(this.webex, 'ready', () => { | ||
// Pre-fetch a KMS encryption key url to improve performance | ||
this.webex.internal.encryption.kms.createUnboundKeys({count: 1}).then((keys) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
promise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I will make it more promise:)
|
||
if (this.registered) { | ||
this.logger.info('Task->register#INFO, Calendar plugin already registered'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should you trigger raindrop register event here as well , if its already registred
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need here, if this.registered is true, it should have triggered the register event here:
return this.webex.internal.device
.register()
.then(() => this.webex.internal.mercury.connect())
.then(() => {
this.listenForEvents();
this.trigger(RAINDROP_REGISTERED);
this.registered = true;
})
|
||
this.stopListeningForEvents(); | ||
|
||
return this.webex.internal.mercury |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you want to un register socket when you un register for task
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems to be a pattern that has emerged. i am not totally sure of it's consequences, but it's done in meetings, ai-assistant, dss, device, and calendar plugins. all of them disconnect from mercury on unregister
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I know, the calendar plugin calls unregister() on beforeunload to release connections when running in site web pages, likely as a protection mechanism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to cause issues @robstax , if someone does a un register on task but they need meetings or other the socket would get disconnected
webex.logout whould dergister device and socket
can we check once , all the other plugin might have un register but might not be calling it , launch the web app , in console do task.unregister and see what happens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arun3528 you are right, it is not safe to disconnect the socket, I have removed related logic and only stop listening the events.
|
||
this.stopListeningForEvents(); | ||
|
||
return this.webex.internal.mercury |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems to be a pattern that has emerged. i am not totally sure of it's consequences, but it's done in meetings, ai-assistant, dss, device, and calendar plugins. all of them disconnect from mercury on unregister
// operation. | ||
this.listenToOnce(this.webex, 'ready', () => { | ||
// Pre-fetch a KMS encryption key url to improve performance | ||
this.webex.internal.encryption.kms.createUnboundKeys({count: 1}).then((keys) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think we should do this. we only do it in calendar plugin and i am not sure why. seems strange
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@robstax Caching an encryption key URL here was intended to improve performance. However, after reviewing the createUnboundKeys implementation, I found it simply connects to Mercury to fetch a key, which should be very fast. I’ll remove this part of the code and run some tests.
}, | ||
|
||
/** | ||
* Explicitly tears down the calendar plugin by de-registering |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these bad copy/pastes in the comments? i see lots of references to calendar plugin in this file in the comments. i don't think that's correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will correct them.
@@ -0,0 +1,50 @@ | |||
const _decryptTextProp = (ctx, name, key, object) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am not sure about that @arun3528 . i think each plugin still needs to manage decrypting mercury events
@@ -0,0 +1,45 @@ | |||
import {isArray} from 'lodash'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arun3528 the decrypt/encrypt flow in the SDK plugins is pretty convoluted and pretty unfriendly to dev. different plugins seem to have adapted other ways of doing it. this task plugin seems to be heavily copying calendar plugin (see: packages/@webex/internal-plugin-calendar/src/calendar.decrypt.helper.js). also ai-assistant plugin did decryption different and just called await this.webex.internal.encryption.decryptText(encryptionKeyUrl, value)
wherever it was needed rather than the payload transformer flow.
COMPLETES #< https://jira-eng-gpk2.cisco.com/jira/browse/WEBEX-436262 >
This pull request addresses
Refer to above Epic, we need to implement a new plugin to support new task management feature
by making the following changes
Add a new plugin internal-plugin-task
Change Type
The following scenarios were tested
The GAI Coding Policy And Copyright Annotation Best Practices
I certified that
Make sure to have followed the contributing guidelines before submitting.