Format ./web/backend/Features/Features.Emails

This commit is contained in:
Aaron Po
2026-06-20 15:09:42 -04:00
parent aadeab3afa
commit 433c3fbe3d
6 changed files with 43 additions and 34 deletions

View File

@@ -14,6 +14,10 @@ public class SendRegistrationEmailHandler(IEmailDispatcher emailDispatcher)
{ {
public Task Handle(SendRegistrationEmailCommand request, CancellationToken cancellationToken) public Task Handle(SendRegistrationEmailCommand request, CancellationToken cancellationToken)
{ {
return emailDispatcher.SendRegistrationEmailAsync(request.FirstName, request.Email, request.ConfirmationToken); return emailDispatcher.SendRegistrationEmailAsync(
request.FirstName,
request.Email,
request.ConfirmationToken
);
} }
} }

View File

@@ -12,9 +12,15 @@ namespace Features.Emails.Commands.SendResendConfirmationEmail;
public class SendResendConfirmationEmailHandler(IEmailDispatcher emailDispatcher) public class SendResendConfirmationEmailHandler(IEmailDispatcher emailDispatcher)
: IRequestHandler<SendResendConfirmationEmailCommand> : IRequestHandler<SendResendConfirmationEmailCommand>
{ {
public Task Handle(SendResendConfirmationEmailCommand request, CancellationToken cancellationToken) public Task Handle(
SendResendConfirmationEmailCommand request,
CancellationToken cancellationToken
)
{ {
return emailDispatcher.SendResendConfirmationEmailAsync(request.FirstName, request.Email, return emailDispatcher.SendResendConfirmationEmailAsync(
request.ConfirmationToken); request.FirstName,
request.Email,
request.ConfirmationToken
);
} }
} }

View File

@@ -7,8 +7,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Infrastructure\Infrastructure.Email\Infrastructure.Email.csproj"/> <ProjectReference Include="..\..\Infrastructure\Infrastructure.Email\Infrastructure.Email.csproj" />
<ProjectReference Include="..\..\Infrastructure\Infrastructure.Email.Templates\Infrastructure.Email.Templates.csproj"/> <ProjectReference Include="..\..\Infrastructure\Infrastructure.Email.Templates\Infrastructure.Email.Templates.csproj" />
<ProjectReference Include="..\..\Shared\Shared.Application\Shared.Application.csproj"/> <ProjectReference Include="..\..\Shared\Shared.Application\Shared.Application.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -29,39 +29,38 @@ public class EmailDispatcher(
/// Builds a confirmation link from the given token, renders the registration welcome email template, /// Builds a confirmation link from the given token, renders the registration welcome email template,
/// and sends it to the newly created user. /// and sends it to the newly created user.
/// </summary> /// </summary>
public async Task SendRegistrationEmailAsync(string firstName, string email, string confirmationToken) public async Task SendRegistrationEmailAsync(
string firstName,
string email,
string confirmationToken
)
{ {
string confirmationLink = string confirmationLink = $"{WebsiteBaseUrl}/users/confirm?token={confirmationToken}";
$"{WebsiteBaseUrl}/users/confirm?token={confirmationToken}";
string emailHtml = string emailHtml = await emailTemplateProvider.RenderUserRegisteredEmailAsync(
await emailTemplateProvider.RenderUserRegisteredEmailAsync( firstName,
firstName, confirmationLink
confirmationLink
);
await emailProvider.SendAsync(
email,
"Welcome to The Biergarten App!",
emailHtml,
true
); );
await emailProvider.SendAsync(email, "Welcome to The Biergarten App!", emailHtml, true);
} }
/// <summary> /// <summary>
/// Builds a confirmation link from the given token, renders the resend-confirmation email template, /// Builds a confirmation link from the given token, renders the resend-confirmation email template,
/// and sends it to the user. /// and sends it to the user.
/// </summary> /// </summary>
public async Task SendResendConfirmationEmailAsync(string firstName, string email, string confirmationToken) public async Task SendResendConfirmationEmailAsync(
string firstName,
string email,
string confirmationToken
)
{ {
string confirmationLink = string confirmationLink = $"{WebsiteBaseUrl}/users/confirm?token={confirmationToken}";
$"{WebsiteBaseUrl}/users/confirm?token={confirmationToken}";
string emailHtml = string emailHtml = await emailTemplateProvider.RenderResendConfirmationEmailAsync(
await emailTemplateProvider.RenderResendConfirmationEmailAsync( firstName,
firstName, confirmationLink
confirmationLink );
);
await emailProvider.SendAsync( await emailProvider.SendAsync(
email, email,