Adds transactional outbox and email verification

Implements outbox pattern for reliable message delivery
Adds email verification flow with Postmark integration
Enhances account registration with secure token generation

Introduces background processing for asynchronous email sending
Implements database-level notification mechanism for message processing
This commit is contained in:
Janus C. H. Knudsen 2026-01-10 11:13:33 +01:00
parent 88812177a9
commit 54b057886c
35 changed files with 1174 additions and 358 deletions

View file

@ -0,0 +1,40 @@
#nullable enable
using Insight.Database;
using PlanTempus.Core.CommandQueries;
using PlanTempus.Core.Database;
namespace PlanTempus.Components.Accounts.ConfirmEmail;
public class ConfirmEmailHandler(IDatabaseOperations databaseOperations) : ICommandHandler<ConfirmEmailCommand>
{
public async Task<CommandResponse> Handle(ConfirmEmailCommand command)
{
using var db = databaseOperations.CreateScope(nameof(ConfirmEmailHandler));
var sql = @"
UPDATE system.accounts
SET email_confirmed = true
WHERE email = @Email AND security_stamp = @Token";
var affectedRows = await db.Connection.ExecuteSqlAsync(sql, new
{
command.Email,
command.Token
});
if (affectedRows == 0)
{
throw new InvalidTokenException();
}
return new CommandResponse(command.CorrelationId, command.GetType().Name, command.TransactionId);
}
}
public class InvalidTokenException : Exception
{
public InvalidTokenException() : base("Invalid or expired verification token")
{
}
}