Skip to content

Commit

Permalink
Update email sending method to return operation result
Browse files Browse the repository at this point in the history
Modified SendAzureCommunicationAsync to return Task<EmailSendOperation> for result handling. Updated TestEmail.cs to log operation ID. Added default case to switch for unsupported sender types.
  • Loading branch information
EdiWang committed Oct 13, 2024
1 parent 87c045c commit 763d1dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Moonglade.Function.Email/AzureCommunicationSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public async Task<EmailSendOperation> SendAsync(CommonMailMessage message)

public static class CommonMailMessageExtensions
{
public static async Task SendAzureCommunicationAsync(this CommonMailMessage message)
public static Task<EmailSendOperation> SendAzureCommunicationAsync(this CommonMailMessage message)
{
var sender = new AzureCommunicationSender();
await sender.SendAsync(message);
return sender.SendAsync(message);
}
}
5 changes: 4 additions & 1 deletion src/Moonglade.Function.Email/TestEmail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ public async Task<IActionResult> Run(
case "smtp":
await message.SendAsync();
break;

case "azurecommunication":
await message.SendAzureCommunicationAsync();
var result = await message.SendAzureCommunicationAsync();
logger.LogInformation($"AzureCommunication operation ID: {result.Id}");
break;

default:
throw new InvalidOperationException("Sender not supported");
}
Expand Down

0 comments on commit 763d1dc

Please sign in to comment.