Skip to content

Commit

Permalink
Fuck
Browse files Browse the repository at this point in the history
  • Loading branch information
fergalmoran committed Sep 23, 2023
1 parent 7f77710 commit 582a178
Show file tree
Hide file tree
Showing 7 changed files with 1,248 additions and 3 deletions.
1 change: 1 addition & 0 deletions mixyboos-api-tests/mixyboos-api-tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Communication.Email" Version="1.0.1" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0-rc.1.23421.29" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0-preview-23424-02" />
Expand Down
1,201 changes: 1,201 additions & 0 deletions mixyboos-api/Logs/log.txt

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions mixyboos-api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,5 @@ private static IHostBuilder CreateHostBuilder(string[] args) {
builder.ClearProviders();
builder.AddConsole();
});

;
}
}
44 changes: 44 additions & 0 deletions mixyboos-api/Services/Helpers/ARMEmailSender.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Threading.Tasks;
using Azure;
using Microsoft.AspNetCore.Identity.UI.Services;
using Azure.Communication.Email;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace MixyBoos.Api.Services.Helpers;

public class ARMMailSender : IEmailSender {
private readonly IConfiguration _config;
private readonly ILogger<ARMMailSender> _logger;

public ARMMailSender(IConfiguration config, ILogger<ARMMailSender> logger) {
_config = config;
_logger = logger;
}

public async Task SendEmailAsync(string email, string subject, string htmlMessage) {
try {
var connectionString = _config["Email:ARMKey"];
if (string.IsNullOrEmpty(connectionString)) {
throw new InvalidOperationException("ARM key is missing");
}

var client = new EmailClient(connectionString);
var operation = await client.SendAsync(
wait: WaitUntil.Completed,
senderAddress: _config["Email:FromAddress"].ToString(),
recipientAddress: email,
subject: subject,
htmlContent: htmlMessage
);
_logger.LogDebug(
"Send email to {Email} with subject {Subject} with tracking id {TrackingId}",
email,
subject,
operation?.Id);
} catch (Exception e) {
_logger.LogError("Error sending email {Error}", e.Message);
}
}
}
1 change: 1 addition & 0 deletions mixyboos-api/mixyboos-api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Communication.Email" Version="1.0.1" />
<PackageReference Include="Bogus" Version="34.0.2"/>
<PackageReference Include="CliWrap" Version="3.6.4"/>
<PackageReference Include="ExpressionDebugger" Version="2.2.1"/>
Expand Down

0 comments on commit 582a178

Please sign in to comment.