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

Don't attempt to send emails if they have no recipients #6637

Merged
merged 13 commits into from
Nov 9, 2018

Conversation

scottbommarito
Copy link
Contributor

@scottbommarito scottbommarito commented Nov 7, 2018

Aligns Gallery with NuGet/ServerCommon#222

Also made some coding style improvements from #6638 that I didn't want to make as part of a hotfix.

[ReleasePrep][2018.11.05]RI Dev into master
<PackageReference Include="NuGet.Services.Messaging">
<Version>2.31.0</Version>
<PackageReference Include="NuGet.Services.Messaging.Email">
<Version>2.36.0-sb-emptyto-2190469</Version>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will align with master build once other PR is out.

@@ -202,11 +202,8 @@
<EmbeddedResource Include="Infrastructure\MigrateUserToOrganization.sql" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="NuGet.Services.Entities">
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 removed these dependencies because they are transitively pulled in by NuGet.Services.Messaging.Email. I thought having this single dependency to rev will make this easier to manage in the future.

I have no problem with reverting this back if you think this isn't a good idea.

{
public static class GalleryEmailRecipientsUtility
{
public static IReadOnlyList<MailAddress> GetAddressesWithPermission(User user, ActionRequiringAccountPermissions action)
Copy link
Contributor Author

@scottbommarito scottbommarito Nov 7, 2018

Choose a reason for hiding this comment

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

This is EmailRecipientsWithPermission.AddAddressesWithPermission, but moved into a static method.

EmailRecipientsWithPermission was an unnecessary extra layer of abstraction so I removed it as part of this PR.
This is the pattern existing in ServerCommon: see EmailRecipients.GetAllOwners and EmailRecipients.GetOwnersSubscribedToPackagePushedNotification.

@scottbommarito scottbommarito changed the base branch from master to dev November 8, 2018 00:54
@@ -31,13 +31,10 @@ public class OrganizationMemberRemovedMessage : MarkdownEmailBuilder

public override IEmailRecipients GetRecipients()
{
if (!Organization.EmailAllowed)
{
return EmailRecipients.None;
Copy link
Contributor Author

@scottbommarito scottbommarito Nov 8, 2018

Choose a reason for hiding this comment

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

I removed the usage of EmailRecipients.None because I think it's misleading. We're using EmailRecipients.None as a signal for "this email shouldn't be sent" when the real signal for when an email shouldn't be sent is whether or not it has any recipients to send to. Because "an email without recipients to send to" and "an email with no recipients at all" are not logically equivalent, this seems odd.

For example, in this function, we return EmailRecipients.None when the intended To address doesn't allow emails. Does whether or not the To address allows emails affect the replyTo field of the email? Technically no. So then why are we returning a completely empty list of recipients when there are people whom replies to the email should go to?

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, good call! 👍

@@ -31,13 +31,10 @@ public class OrganizationMemberRemovedMessage : MarkdownEmailBuilder

public override IEmailRecipients GetRecipients()
{
if (!Organization.EmailAllowed)
{
return EmailRecipients.None;
Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, good call! 👍

agr and others added 7 commits November 9, 2018 12:57
Enabling accepting license metadata. License files are not yet allowed.
* Package delete was broken with recent update. This fixes it.

* Moved folder names into its own class.
Updated tests to include All folders.

* Added tests to verify all folders are covered by tests.
* Upload license expression redirect url logic

* fix nit and update
Take new version of ServerCommon to GalleryCore.
@scottbommarito scottbommarito merged commit 9855ce7 into dev Nov 9, 2018
@scottbommarito scottbommarito deleted the sb-fixemailrecipients branch November 9, 2018 21:31
@scottbommarito scottbommarito restored the sb-fixemailrecipients branch July 22, 2019 23:21
@scottbommarito scottbommarito deleted the sb-fixemailrecipients branch July 22, 2019 23:21
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.

8 participants