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

Move email sending for adding a package owner into the service layer #8769

Merged
merged 6 commits into from
Sep 4, 2021

Conversation

joelverhagen
Copy link
Member

@joelverhagen joelverhagen commented Aug 28, 2021

Today, all of our emails (except one for AccountDeleter) are send in the ASP.NET Controller layer. This means if another location needs to perform a similar bit of business logic, the email sending code is duplicated.

This PR currently moves a single email send down from the Controller layer into the Service layer. The pieces of the PR of note are:

  1. Introduce an IUrlHelper abstraction so the service layer can generate URLs.
  2. Add IPackageOwnershipManagementService.AddPackageOwnerWithMessagesAsync.
  3. Use this new method in 2 of the 3 places where owners are added (both of which are already sending mail).

This change also closes a gap in behavior where in one case the newly added owner got an email and in another case they did not. I aligned the behavior so that all owners, new and old, got the notification email.

Alternatives considered:

  • Adding a new IPackageOwnershipMessageService which has this AddPackageOwnerWithMessagesAsync method. I thought adding a new method to and existing interface was better.
  • Making the AddPackageOwnerWithMessagesAsync method have a string packageUrl parameter so IUrlHelper needn't exist. I didn't like this pattern since some emails that would be sent from the service layer need many URLs and therefore would have many URL parameters on their *WithMessagesAsync methods.

Thoughts?

This is related to https://github.com/NuGet/Engineering/issues/3994, which will need these service layer operations to send email.
Progress on https://github.com/NuGet/Engineering/issues/4034.

@joelverhagen joelverhagen marked this pull request as ready for review August 30, 2021 20:59
@joelverhagen joelverhagen requested a review from a team as a code owner August 30, 2021 20:59
@joelverhagen joelverhagen changed the title Move emails about ownership changes into the service layer Move email sending for adding a package owner into the service layer Sep 2, 2021
@joelverhagen joelverhagen merged commit b88d286 into dev Sep 4, 2021
@joelverhagen joelverhagen deleted the jver-service-mail branch September 4, 2021 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants