Refactor SendEmailAsync to use EmailContext object
Simplified the `SendEmailAsync` method in the `IEmailService` interface to accept a single `EmailContext` object instead of multiple parameters. Updated the `SendingEmailConsumer` and `LimilabsEmailService` classes to align with this change. In `LimilabsEmailService`, refactored email construction logic to use properties from the `EmailContext` object, including `Sender`, `Recipients`, `Subject`, `Body`, and `IsHtml`. Updated `ConnectAndAuthenticateSmtpAsync` to use the `Sender` property from `EmailContext`. These changes improve code readability, reduce parameter complexity, and ensure consistency across the email service implementation.
This commit is contained in:
@@ -47,12 +47,7 @@ public sealed class SendingEmailConsumer : IAsyncDisposable
|
||||
if (oMailEvent is not null)
|
||||
{
|
||||
// Send email via SMTP (SMTP config is injected in IEmailService via IOptions)
|
||||
await EmailService.SendEmailAsync(
|
||||
oMailEvent.Mail.Sender,
|
||||
oMailEvent.Mail.Recipients,
|
||||
oMailEvent.Mail.Subject,
|
||||
oMailEvent.Mail.Body,
|
||||
isHtml: oMailEvent.Mail.IsHtml);
|
||||
await EmailService.SendEmailAsync(oMailEvent.Mail);
|
||||
|
||||
// Acknowledge message after successful processing
|
||||
await channel.BasicAckAsync(args.DeliveryTag, false, args.CancellationToken);
|
||||
|
||||
Reference in New Issue
Block a user