removed unused code

This commit is contained in:
Mia Rose Winter 2024-02-28 11:48:51 +01:00
parent 17ab022bbe
commit f1cb3d730b
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E
2 changed files with 2 additions and 15 deletions

View file

@ -148,7 +148,6 @@
if (emailConfig.Smtp.Keys.Any(k => k.Equals("live", StringComparison.CurrentCultureIgnoreCase))) { if (emailConfig.Smtp.Keys.Any(k => k.Equals("live", StringComparison.CurrentCultureIgnoreCase))) {
builder.Services.AddScoped(sp => sp.GetKeyedService<IEmailService>("live")!); builder.Services.AddScoped(sp => sp.GetKeyedService<IEmailService>("live")!);
builder.Services.AddScoped<IEmailSender, SmtpEmailSender>();
builder.Services.AddScoped<IEmailSender<ApplicationUser>, SmtpEmailSender>(); builder.Services.AddScoped<IEmailSender<ApplicationUser>, SmtpEmailSender>();
} else { } else {
builder.Services.AddSingleton<IEmailSender<ApplicationUser>, IdentityNoOpEmailSender>(); builder.Services.AddSingleton<IEmailSender<ApplicationUser>, IdentityNoOpEmailSender>();

View file

@ -1,14 +1,11 @@
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI.Services;
using Wave.Data; using Wave.Data;
using Wave.Utilities;
namespace Wave.Services; namespace Wave.Services;
public class SmtpEmailSender(EmailFactory email, [FromKeyedServices("live")]IEmailService emailService, [FromKeyedServices("bulk")]IEmailService bulkEmailService) : IEmailSender<ApplicationUser>, IEmailSender, IAsyncDisposable { public class SmtpEmailSender(EmailFactory email, [FromKeyedServices("live")]IEmailService emailService) : IEmailSender<ApplicationUser>, IAsyncDisposable {
private EmailFactory Email { get; } = email; private EmailFactory Email { get; } = email;
private IEmailService EmailService { get; } = emailService; private IEmailService EmailService { get; } = emailService;
private IEmailService BulkEmailService { get; } = bulkEmailService;
#region IEmailSenderAsync<ApplicationUser> #region IEmailSenderAsync<ApplicationUser>
@ -29,15 +26,7 @@ public class SmtpEmailSender(EmailFactory email, [FromKeyedServices("live")]IEma
#endregion #endregion
#region IEmailSender private async Task SendDefaultMailAsync(string receiverMail, string? receiverName, string subject, string title, string bodyHtml, string bodyPlain) {
public Task SendEmailAsync(string email, string subject, string htmlMessage) {
return SendDefaultMailAsync(email, null, subject, subject, htmlMessage, HtmlUtilities.GetPlainText(htmlMessage));
}
#endregion
public async Task SendDefaultMailAsync(string receiverMail, string? receiverName, string subject, string title, string bodyHtml, string bodyPlain) {
await EmailService.ConnectAsync(CancellationToken.None); await EmailService.ConnectAsync(CancellationToken.None);
var email = await Email.CreateDefaultEmail(receiverMail, receiverName, subject, title, bodyHtml, bodyPlain); var email = await Email.CreateDefaultEmail(receiverMail, receiverName, subject, title, bodyHtml, bodyPlain);
await EmailService.SendEmailAsync(email); await EmailService.SendEmailAsync(email);
@ -47,6 +36,5 @@ public class SmtpEmailSender(EmailFactory email, [FromKeyedServices("live")]IEma
public async ValueTask DisposeAsync() { public async ValueTask DisposeAsync() {
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
await EmailService.DisposeAsync(); await EmailService.DisposeAsync();
await BulkEmailService.DisposeAsync();
} }
} }