Skip to content

Commit

Permalink
Don't throw when inviting guest users to project (#1077)
Browse files Browse the repository at this point in the history
Guest users don't have email addresses, but they can be invited to
projects. So when sending the "You've been invited to project X" email,
if the user doesn't have an email address, that's not an error that
should cause an exception to be thrown. It just means that that user is
a guest user without an email, so we should just skip emailing them.
  • Loading branch information
rmunn authored Sep 27, 2024
1 parent 808dae9 commit 634bb92
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion backend/LexBoxApi/Services/EmailService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ await RenderEmail(email,
}
public async Task SendUserAddedEmail(User user, string projectName, string projectCode)
{
var email = StartUserEmail(user) ?? throw new ArgumentNullException("emailAddress");
var email = StartUserEmail(user);
if (email is null) return; // Guest users have no email address, so we won't notify them by email and that's not an error
await RenderEmail(email, new UserAddedEmail(user.Name, user.Email!, projectName, projectCode), user.LocalizationCode);
await SendEmailWithRetriesAsync(email);
}
Expand Down

0 comments on commit 634bb92

Please sign in to comment.