From 2f28ac9350e21c0b53a9005e60b9344541651ecf Mon Sep 17 00:00:00 2001 From: Aaron Po Date: Sat, 20 Jun 2026 15:13:01 -0400 Subject: [PATCH] Format ./web/backend/Infrastructure/Infrastructure.Email --- .../Infrastructure.Email/IEmailProvider.cs | 9 +---- .../Infrastructure.Email.csproj | 2 +- .../Infrastructure.Email/SmtpEmailProvider.cs | 40 +++++-------------- 3 files changed, 14 insertions(+), 37 deletions(-) diff --git a/web/backend/Infrastructure/Infrastructure.Email/IEmailProvider.cs b/web/backend/Infrastructure/Infrastructure.Email/IEmailProvider.cs index 7efd462..bf46675 100644 --- a/web/backend/Infrastructure/Infrastructure.Email/IEmailProvider.cs +++ b/web/backend/Infrastructure/Infrastructure.Email/IEmailProvider.cs @@ -21,10 +21,5 @@ public interface IEmailProvider /// Email subject line /// Email body (HTML or plain text) /// Whether the body is HTML (default: true) - Task SendAsync( - IEnumerable to, - string subject, - string body, - bool isHtml = true - ); -} \ No newline at end of file + Task SendAsync(IEnumerable to, string subject, string body, bool isHtml = true); +} diff --git a/web/backend/Infrastructure/Infrastructure.Email/Infrastructure.Email.csproj b/web/backend/Infrastructure/Infrastructure.Email/Infrastructure.Email.csproj index f95550c..1ce8eb9 100644 --- a/web/backend/Infrastructure/Infrastructure.Email/Infrastructure.Email.csproj +++ b/web/backend/Infrastructure/Infrastructure.Email/Infrastructure.Email.csproj @@ -7,6 +7,6 @@ - + diff --git a/web/backend/Infrastructure/Infrastructure.Email/SmtpEmailProvider.cs b/web/backend/Infrastructure/Infrastructure.Email/SmtpEmailProvider.cs index 706fca8..5b15f1a 100644 --- a/web/backend/Infrastructure/Infrastructure.Email/SmtpEmailProvider.cs +++ b/web/backend/Infrastructure/Infrastructure.Email/SmtpEmailProvider.cs @@ -58,22 +58,16 @@ public class SmtpEmailProvider : IEmailProvider { _host = Environment.GetEnvironmentVariable("SMTP_HOST") - ?? throw new InvalidOperationException( - "SMTP_HOST environment variable is not set" - ); + ?? throw new InvalidOperationException("SMTP_HOST environment variable is not set"); - string portString = - Environment.GetEnvironmentVariable("SMTP_PORT") ?? "587"; + string portString = Environment.GetEnvironmentVariable("SMTP_PORT") ?? "587"; if (!int.TryParse(portString, out _port)) - throw new InvalidOperationException( - $"SMTP_PORT '{portString}' is not a valid integer" - ); + throw new InvalidOperationException($"SMTP_PORT '{portString}' is not a valid integer"); _username = Environment.GetEnvironmentVariable("SMTP_USERNAME"); _password = Environment.GetEnvironmentVariable("SMTP_PASSWORD"); - string useSslString = - Environment.GetEnvironmentVariable("SMTP_USE_SSL") ?? "true"; + string useSslString = Environment.GetEnvironmentVariable("SMTP_USE_SSL") ?? "true"; _useSsl = bool.Parse(useSslString); _fromEmail = @@ -82,9 +76,7 @@ public class SmtpEmailProvider : IEmailProvider "SMTP_FROM_EMAIL environment variable is not set" ); - _fromName = - Environment.GetEnvironmentVariable("SMTP_FROM_NAME") - ?? "The Biergarten"; + _fromName = Environment.GetEnvironmentVariable("SMTP_FROM_NAME") ?? "The Biergarten"; } /// @@ -95,12 +87,7 @@ public class SmtpEmailProvider : IEmailProvider /// Email body (HTML or plain text) /// Whether the body is HTML (default: true) /// Thrown when connecting, authenticating, or sending via SMTP fails. - public async Task SendAsync( - string to, - string subject, - string body, - bool isHtml = true - ) + public async Task SendAsync(string to, string subject, string body, bool isHtml = true) { await SendAsync([to], subject, body, isHtml); } @@ -128,7 +115,8 @@ public class SmtpEmailProvider : IEmailProvider MimeMessage message = new(); message.From.Add(new MailboxAddress(_fromName, _fromEmail)); - foreach (string recipient in to) message.To.Add(MailboxAddress.Parse(recipient)); + foreach (string recipient in to) + message.To.Add(MailboxAddress.Parse(recipient)); message.Subject = subject; @@ -152,10 +140,7 @@ public class SmtpEmailProvider : IEmailProvider await client.ConnectAsync(_host, _port, secureSocketOptions); // Authenticate if credentials are provided - if ( - !string.IsNullOrEmpty(_username) - && !string.IsNullOrEmpty(_password) - ) + if (!string.IsNullOrEmpty(_username) && !string.IsNullOrEmpty(_password)) await client.AuthenticateAsync(_username, _password); await client.SendAsync(message); @@ -163,10 +148,7 @@ public class SmtpEmailProvider : IEmailProvider } catch (Exception ex) { - throw new InvalidOperationException( - $"Failed to send email: {ex.Message}", - ex - ); + throw new InvalidOperationException($"Failed to send email: {ex.Message}", ex); } } -} \ No newline at end of file +}