Refactor email account handling for dynamic resolution

Reintroduced `EmailAccountDto` with conditional compilation to support both .NET and non-.NET environments. Updated `IEmailService` to accept `EmailAccountDto` as the sender, replacing reliance on pre-configured SMTP credentials.

Added `GetSenderQuery` and its handler to dynamically resolve email accounts based on `Id` or `Username`. Introduced `GetSenderQueryValidator` for validation, ensuring proper usage of the query.

Modified `SendEmailCommand` to include sender resolution via MediatR. Updated `OutgoingEmailEvent` to include sender information and adjusted `OutgoingEmailConsumer` and `LimilabsEmailService` to use the dynamically resolved sender.

Updated `EmailMappingProfile` to ignore the `Sender` property during mapping. Replaced `Name` with `Id` in `appsettings.Secrets.json` for email accounts. Removed the old `EmailAccountDto` folder and performed general cleanup and restructuring.
This commit is contained in:
2026-08-05 12:32:08 +02:00
parent 7fa3c4888a
commit 740bb8c313
12 changed files with 136 additions and 45 deletions

View File

@@ -12,8 +12,10 @@ public class EmailMappingProfile : Profile
public EmailMappingProfile()
{
// SendEmailCommand -> OutgoingEmailEvent
// Sender is resolved via MediatR in the handler and set separately after mapping.
CreateMap<SendEmailCommand, OutgoingEmailEvent>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(_ => Guid.NewGuid()))
.ForMember(dest => dest.QueuedAt, opt => opt.MapFrom(_ => DateTime.Now));
.ForMember(dest => dest.QueuedAt, opt => opt.MapFrom(_ => DateTime.Now))
.ForMember(dest => dest.Sender, opt => opt.Ignore());
}
}