From 3830717633df949cfd259838307870c999f94a95 Mon Sep 17 00:00:00 2001 From: Mia Winter Date: Sun, 18 Feb 2024 19:30:51 +0100 Subject: [PATCH] fixed service validation exception when no email is configured --- Wave/Program.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Wave/Program.cs b/Wave/Program.cs index a31946e..d0d05e6 100644 --- a/Wave/Program.cs +++ b/Wave/Program.cs @@ -129,6 +129,8 @@ "Email providers have been configured, but no SenderEmail. " + "Please provider the sender email address used for email distribution."); } + builder.Services.AddSingleton(); + builder.Services.AddScoped(); foreach (var smtp in emailConfig.Smtp) { builder.Services.AddKeyedScoped(smtp.Key.ToLower(), (provider, key) => @@ -147,6 +149,7 @@ if (emailConfig.Smtp.Keys.Any(k => k.Equals("bulk", StringComparison.CurrentCultureIgnoreCase))) { builder.Services.AddScoped(); + builder.Services.AddHostedService(); } else if (builder.Configuration.GetSection(nameof(Features)).Get()?.EmailSubscriptions is not true) { throw new ApplicationException( "Email subscriptions have been enabled, but no 'bulk' email provider was configured. " + @@ -157,12 +160,8 @@ logMessages.Add("No email provider configured."); } -builder.Services.AddScoped(); - builder.Services.AddSingleton(); builder.Services.AddSingleton(); -builder.Services.AddSingleton(); -builder.Services.AddHostedService(); #endregion