Refactor email services and update password handling
Updated `EmailAccountDto` to use `required` properties for .NET 7+ compatibility, removing the `PasswordEncrypted` property and simplifying password handling. Removed `IEncryptionService` dependency from `LimilabsEmailService` and `LimilabsImapEmailService`. Updated `ConnectAndAuthenticateSmtpAsync` and `OpenAsync` methods to remove password decryption logic. Introduced `CancellationToken` support in `LimilabsImapEmailService` methods to improve cancellation handling for IMAP operations. Added `Entities\` folder reference in `DigitalData.MessagingService.Domain.csproj`.
This commit is contained in:
@@ -16,8 +16,7 @@ namespace DigitalData.MessagingService.Infrastructure.Services;
|
||||
/// Uses the first account in the list whose <see cref="EmailAccountDto.Name"/> equals <c>"default"</c>,
|
||||
/// or falls back to the first account if none is named "default".
|
||||
/// </summary>
|
||||
public class LimilabsEmailService(
|
||||
IEncryptionService encryptionService) : IEmailService
|
||||
public class LimilabsEmailService() : IEmailService
|
||||
{
|
||||
// Register encoding provider for Limilabs (requires windows-1252 and other code pages)
|
||||
static LimilabsEmailService()
|
||||
@@ -71,7 +70,7 @@ public class LimilabsEmailService(
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ConnectAndAuthenticateSmtpAsync(Smtp smtp, EmailAccountDto smtpAccount)
|
||||
private static async Task ConnectAndAuthenticateSmtpAsync(Smtp smtp, EmailAccountDto smtpAccount)
|
||||
{
|
||||
if (smtpAccount.SmtpUseSsl)
|
||||
{
|
||||
@@ -88,9 +87,7 @@ public class LimilabsEmailService(
|
||||
}
|
||||
else
|
||||
{
|
||||
var password = smtpAccount.PasswordEncrypted ? encryptionService.Decrypt(smtpAccount.Password) : smtpAccount.Password;
|
||||
|
||||
await smtp.LoginAsync(smtpAccount.Username, password);
|
||||
await smtp.LoginAsync(smtpAccount.Username, smtpAccount.Password);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user