From 634bb92effdd2e5edbf68c0a2609837825a07dfa Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Fri, 27 Sep 2024 08:49:18 +0700 Subject: [PATCH] Don't throw when inviting guest users to project (#1077) 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. --- backend/LexBoxApi/Services/EmailService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/LexBoxApi/Services/EmailService.cs b/backend/LexBoxApi/Services/EmailService.cs index b1a11a77c..2e8ce7b52 100644 --- a/backend/LexBoxApi/Services/EmailService.cs +++ b/backend/LexBoxApi/Services/EmailService.cs @@ -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); }