refactor(client)!: return Task from EmailSender.Send

Await ISendingEmailPublisher.EnqueueAsync so publish failures surface to the caller instead of being lost in a fire-and-forget call.

BREAKING CHANGE: EmailSender.Send now returns Task and must be awaited. Synchronous callers that relied on exceptions being thrown directly from Send will no longer observe them.
This commit is contained in:
2026-11-02 10:11:27 +01:00
parent afc1a434db
commit 11ba3cdac4

View File

@@ -120,13 +120,13 @@ public static class EmailSender
/// Ensure that any unhandled exceptions from the async operation are handled
/// at the publisher level.
/// </remarks>
public static void Send(EmailContext email)
public static async Task Send(EmailContext email)
{
if(!IsConnected)
throw new InvalidOperationException("Messaging service is not connected. Call ConnectRabbitMq first.");
var publisher = LazyProvider.Value.GetRequiredService<ISendingEmailPublisher>();
publisher.EnqueueAsync(new SendingEmailEvent()
await publisher.EnqueueAsync(new SendingEmailEvent()
{
Id = Guid.NewGuid(),
Mail = email,