-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Nv 2215 delete messagetemplates of deleted templates #3524
Nv 2215 delete messagetemplates of deleted templates #3524
Conversation
NV-2215 delete messageTemplates of deleted templates
Why? (Context)Within each Template, we have steps. each step has messageTemplate (content). When the user delete the templates, message templates are not deleted. What?As message templates are still there without the parent template, in the case of an in-app step, the feed is associated with the message template, User is not able to delete the feed Definition of Done
|
5e07a28
to
c24ada1
Compare
reset({ | ||
...form, | ||
steps: response.steps, | ||
}); |
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 fixes the issue where multiple duplicate message templates were being created while updating the Notification template from the UI, also fixes the deletion of feed error.
Steps to reproduce(without this code change):
- Create a new workflow
- add an in-app step, fill the details
- within the in-app editor screen, click update button
- go back, and add another in-app step
- keep the second in-app editor screen open, click update
- do some minor changes in the content, click update
- Check DB, there will be multiple copies of the 2nd step.
@LetItRock You added this for some digest related issue. can you please confirm if this change works for that issue?
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.
Great job @BiswaViraj🤩
I just have a few concerns:
- Let's do a soft delete of the message template like we do for the other repositories.
- In promoting the notification template change it calls the promote message template, which currently has no delete behavior.
- When removing a step - not in the delete template - what do you think of also deleting the message template? I believe we are just updating the notification template now.
- Lets add a couple of tests for the promotion of notification template promotes deletion of the message templates + able to delete a feed.
@@ -139,6 +145,47 @@ describe('Delete notification template by id - /notification-templates/:template | |||
|
|||
expect(response.body.message).to.contains('Could not find workflow with id'); | |||
}); | |||
|
|||
it('should delete the notification template along with the message templates', async function () { |
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.
What do you think about also adding a test of deleting a notification template that has a feed assigned to it and then see that the feed can be deleted?
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.
Agree, that will be a good addition, will add it.
item: template, | ||
type: ChangeEntityTypeEnum.MESSAGE_TEMPLATE, | ||
parentChangeId: command.parentChangeId, | ||
changeId: MessageTemplateRepository.createObjectId(), |
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 believe here changeId should get the value from changeRepository.getChangeId
because then it will aggregate all current changes made to that message template into one.
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.
🌟
const template = await this.messageTemplateRepository.findById(command.messageTemplateId, command.environmentId); | ||
if (!template) { | ||
throw new NotFoundException(`Message Template with id ${command.messageTemplateId} not found`); | ||
} |
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 a tech debt we should create an use case to find the message template to handle this logic as it can be reused in UpdateMessageTemplate
.
const deletedIntegration = ( | ||
await notificationTemplateRepository.findDeleted({ _environmentId: session.environment._id, _id: template._id }) | ||
)[0]; |
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.
const deletedIntegration = ( | |
await notificationTemplateRepository.findDeleted({ _environmentId: session.environment._id, _id: template._id }) | |
)[0]; | |
const [deletedIntegration] = await notificationTemplateRepository.findDeleted({ _environmentId: session.environment._id, _id: template._id }); |
Same vibes. 🙂
Not to address it as it is stylistic and we have no defined preference for any.
await this.deleteMessageTemplate.execute( | ||
DeleteMessageTemplateCommand.create({ | ||
organizationId: command.organizationId, | ||
environmentId: command.environmentId, | ||
userId: command.userId, | ||
messageTemplateId: step._templateId, | ||
parentChangeId: parentChangeId, |
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.
Do we want to stop the execution of the notification template deletion if any of the message template deletions fail?
c24ada1
to
e017019
Compare
b962087
to
705b3e7
Compare
What change does this PR introduce?
Why was this change needed?
Other information (Screenshots)