mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-07-16 17:47:22 +00:00
Format ./web/backend/Features/Features.Emails
This commit is contained in:
@@ -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
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,4 +17,4 @@ public static class FeaturesEmailsServiceCollectionExtensions
|
|||||||
services.AddScoped<IEmailDispatcher, EmailDispatcher>();
|
services.AddScoped<IEmailDispatcher, EmailDispatcher>();
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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,
|
||||||
@@ -70,4 +69,4 @@ public class EmailDispatcher(
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,4 +22,4 @@ public interface IEmailDispatcher
|
|||||||
/// <param name="confirmationToken">The confirmation token to embed in the confirmation link.</param>
|
/// <param name="confirmationToken">The confirmation token to embed in the confirmation link.</param>
|
||||||
/// <returns>A task that completes once the email has been sent.</returns>
|
/// <returns>A task that completes once the email has been sent.</returns>
|
||||||
Task SendResendConfirmationEmailAsync(string firstName, string email, string confirmationToken);
|
Task SendResendConfirmationEmailAsync(string firstName, string email, string confirmationToken);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user