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:
2026-08-12 14:24:17 +02:00
parent 176e6dd6c5
commit 5e0de6d52a
4 changed files with 24 additions and 29 deletions

View File

@@ -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);
}
}