-
Notifications
You must be signed in to change notification settings - Fork 641
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
Changes from all commits
bf7e98f
51f4085
0b177de
0adedfd
fc932f6
e43bd55
2284a50
4426053
236df59
1a4da8d
7bb631c
3db0bf3
052dfba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,19 +6,12 @@ | |
using System.Linq; | ||
using System.Net.Mail; | ||
using NuGet.Services.Entities; | ||
using NuGet.Services.Messaging.Email; | ||
|
||
namespace NuGetGallery.Infrastructure.Mail | ||
{ | ||
public class EmailRecipientsWithPermission | ||
: IEmailRecipients | ||
public static class GalleryEmailRecipientsUtility | ||
{ | ||
public EmailRecipientsWithPermission( | ||
User user, | ||
ActionRequiringAccountPermissions action, | ||
IReadOnlyList<MailAddress> cc = null, | ||
IReadOnlyList<MailAddress> bcc = null, | ||
IReadOnlyList<MailAddress> replyTo = null) | ||
public static IReadOnlyList<MailAddress> GetAddressesWithPermission(User user, ActionRequiringAccountPermissions action) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is
|
||
{ | ||
if (user == null) | ||
{ | ||
|
@@ -30,23 +23,6 @@ public EmailRecipientsWithPermission( | |
throw new ArgumentNullException(nameof(action)); | ||
} | ||
|
||
To = AddAddressesWithPermission(user, action); | ||
|
||
CC = cc ?? new List<MailAddress>(); | ||
Bcc = bcc ?? new List<MailAddress>(); | ||
ReplyTo = replyTo ?? new List<MailAddress>(); | ||
} | ||
|
||
public IReadOnlyList<MailAddress> To { get; } | ||
|
||
public IReadOnlyList<MailAddress> CC { get; } | ||
|
||
public IReadOnlyList<MailAddress> Bcc { get; } | ||
|
||
public IReadOnlyList<MailAddress> ReplyTo { get; } | ||
|
||
private static IReadOnlyList<MailAddress> AddAddressesWithPermission(User user, ActionRequiringAccountPermissions action) | ||
{ | ||
var recipients = new List<MailAddress>(); | ||
|
||
if (user is Organization organization) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,13 +31,10 @@ public OrganizationMemberRemovedMessage( | |
|
||
public override IEmailRecipients GetRecipients() | ||
{ | ||
if (!Organization.EmailAllowed) | ||
{ | ||
return EmailRecipients.None; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed the usage of For example, in this function, we return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense, good call! 👍 |
||
} | ||
|
||
return new EmailRecipients( | ||
to: new[] { Organization.ToMailAddress() }, | ||
to: Organization.EmailAllowed | ||
? new[] { Organization.ToMailAddress() } | ||
: new MailAddress[0], | ||
replyTo: new[] { RemovedUser.ToMailAddress() }); | ||
} | ||
|
||
|
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 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.