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

Add notification group endpoints #3274

Merged
merged 8 commits into from
May 4, 2023

Conversation

peoray
Copy link
Contributor

@peoray peoray commented Apr 23, 2023

What change does this PR introduce?

Related to #1321

Why was this change needed?

Other information (Screenshots)

@peoray peoray changed the title feat(api): Add endpoint to get a notification group Add notification group endpoints Apr 23, 2023
@peoray
Copy link
Contributor Author

peoray commented Apr 23, 2023

@p-fernandez please review :)
cc @florian-lefebvre

@peoray peoray marked this pull request as ready for review April 23, 2023 15:56
@florian-lefebvre
Copy link
Contributor

I'm glad someone is working on this again! I'm no able to review your PR because I'm not familiar enough with the codebase, but I'm sure someone from the Novu team will eventually takes care of it

Copy link
Contributor

@p-fernandez p-fernandez left a comment

Choose a reason for hiding this comment

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

Thanks for this work! Some comments to discuss and few improvements.

Comment on lines 34 to 41
const result = await this.notificationGroupRepository.findOne({
_environmentId: environmentId,
_id: id,
});

if (!result) {
throw new NotFoundException(`Notification group with id ${id} not found`);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of doing this you can check inside the NotificationGroupRepository if the response from the update method returns that an entry has been changed and manage the logic accordingly.
Also it feels a bit weird that you check again if the group exists after updating it when you have already checked it before updating it. 🤔

Copy link
Contributor Author

@peoray peoray May 3, 2023

Choose a reason for hiding this comment

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

I need to return an object of the update code as per the NotificationGroupResponseDto and the update method return an object of matched and modified

Comment on lines +12 to +18
@ApiProperty({
description: 'The status enum for the performed action',
enum: ['deleted'],
})
@IsString()
@IsDefined()
status: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason behind adding this status to the API response of a call that from the method we know it is a delete call? Did you have something in mind that in the future we could benefit from having a status?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got this from the issue, @scopsy mentioned it somewhere. Also, we have similar in the remove-subscribe usecase

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not particularly fan of returning 200 status for successful delete calls as I consider it complicates consumer's logic besides not adding extra useful information. As it is an implementation detail requested I will discuss it in the core team. 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright then.

Unrelated, but I admired your eye for detail and thorough reviews, especially for the PRs I have raised so far. It helps me to understand the codebase better and overall, a skill I want to emulate.

Copy link
Contributor

@p-fernandez p-fernandez left a comment

Choose a reason for hiding this comment

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

🌟

@p-fernandez p-fernandez added this pull request to the merge queue May 4, 2023
Merged via the queue into novuhq:next with commit 03a4489 May 4, 2023
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.

3 participants