Skip to content

Commit

Permalink
removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
miawinter98 committed Feb 28, 2024
1 parent 17ab022 commit f1cb3d7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
1 change: 0 additions & 1 deletion Wave/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@

if (emailConfig.Smtp.Keys.Any(k => k.Equals("live", StringComparison.CurrentCultureIgnoreCase))) {
builder.Services.AddScoped(sp => sp.GetKeyedService<IEmailService>("live")!);
builder.Services.AddScoped<IEmailSender, SmtpEmailSender>();
builder.Services.AddScoped<IEmailSender<ApplicationUser>, SmtpEmailSender>();
} else {
builder.Services.AddSingleton<IEmailSender<ApplicationUser>, IdentityNoOpEmailSender>();
Expand Down
16 changes: 2 additions & 14 deletions Wave/Services/SmtpEmailSender.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI.Services;
using Wave.Data;
using Wave.Utilities;

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 IEmailService EmailService { get; } = emailService;
private IEmailService BulkEmailService { get; } = bulkEmailService;

#region IEmailSenderAsync<ApplicationUser>

Expand All @@ -29,15 +26,7 @@ public Task SendPasswordResetCodeAsync(ApplicationUser user, string email, strin

#endregion

#region IEmailSender

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) {
private async Task SendDefaultMailAsync(string receiverMail, string? receiverName, string subject, string title, string bodyHtml, string bodyPlain) {
await EmailService.ConnectAsync(CancellationToken.None);
var email = await Email.CreateDefaultEmail(receiverMail, receiverName, subject, title, bodyHtml, bodyPlain);
await EmailService.SendEmailAsync(email);
Expand All @@ -47,6 +36,5 @@ public async Task SendDefaultMailAsync(string receiverMail, string? receiverName
public async ValueTask DisposeAsync() {
GC.SuppressFinalize(this);
await EmailService.DisposeAsync();
await BulkEmailService.DisposeAsync();
}
}

0 comments on commit f1cb3d7

Please sign in to comment.