Skip to content
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

🐛 CreateNotificationJobCommand fix - update templateProviderIds Map to Record. #3614

Merged
merged 5 commits into from
Jun 25, 2023

Conversation

djabarovgeorge
Copy link
Contributor

@djabarovgeorge djabarovgeorge commented Jun 18, 2023

What change does this PR introduce?

Changed the templateProviderIds Map to Record.

Why was this change needed?

Looks like the plainToInstance (from 'class-transformer') in the BaseCommand is mapping Map values to 'undefined'.

Other information (Screenshots)

typestack/class-transformer#1256

@djabarovgeorge djabarovgeorge changed the title fix: update lock file after next merge 🐛 CreateNotificationJobCommand fix - update templateProviderIds Map to Record. Jun 19, 2023
@scopsy
Copy link
Contributor

scopsy commented Jun 19, 2023

@djabarovgeorge do we have any way to create a test case for this value? I think it's the second time it's doing problems :(

@djabarovgeorge
Copy link
Contributor Author

@djabarovgeorge do we have any way to create a test case for this value? I think it's the second time it's doing problems :(

Do you mean that templateProviderIds is doing problems?

@scopsy
Copy link
Contributor

scopsy commented Jun 19, 2023

@djabarovgeorge yes, it caused some issue previously with undefined values for providerId when the job is created. It was fixed later, but now seems there is another issue in that area.

@@ -241,14 +242,14 @@ export class TriggerEvent {
channelType
);
if (provider) {
providers.set(channelType, provider);
providers[channelType] = provider;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this to cause problems for example in the email channel with the Novu provider plus the email provider a user might enable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the current logic, I think that this.getProviderId will return not novu integration if exists. and then set it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and won't return the novu email integration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will first of all return, not Novu integration if exist, and if not it will return Novu's integration.

);
const channel = STEP_TYPE_TO_CHANNEL_TYPE.get(
step.template.type
) as ChannelTypeEnum;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel we should change the STEP_TYPE_TO_CHANNEL_TYPE to object as we now need to cast the value always

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the cast was not needed at all so i removed it.

@@ -241,14 +242,14 @@ export class TriggerEvent {
channelType
);
if (provider) {
providers.set(channelType, provider);
providers[channelType] = provider;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and won't return the novu email integration?

@@ -196,6 +196,7 @@ export class SendMessageInApp extends SendMessageBase {
transactionId: command.transactionId,
content: this.storeContent() ? content : null,
payload: messagePayload,
providerId: integration.providerId,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

funny thing, we did not save the provider on the message, which also means that the previous query of oldMessage always failed.

@@ -257,7 +258,7 @@ export class SendMessageInApp extends SendMessageBase {
CreateExecutionDetailsCommand.create({
...CreateExecutionDetailsCommand.getDetailsFromJob(command.job),
messageId: message._id,
providerId: InAppProviderIdEnum.Novu,
providerId: integration.providerId,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added dynamic provider id

@@ -296,7 +297,7 @@ export class SendMessageInApp extends SendMessageBase {
CreateExecutionDetailsCommand.create({
...CreateExecutionDetailsCommand.getDetailsFromJob(command.job),
messageId: message._id,
providerId: InAppProviderIdEnum.Novu,
providerId: integration.providerId,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was not sure where to put it so i left it on the trigger e2e.

@djabarovgeorge djabarovgeorge added this pull request to the merge queue Jun 25, 2023
Merged via the queue into next with commit c0e7b3b Jun 25, 2023
@djabarovgeorge djabarovgeorge deleted the fix-create-notification-jobs-command-mapping branch June 25, 2023 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants