25 lines
897 B
C#
25 lines
897 B
C#
using Socialize.Api.Infrastructure.Emailer.Contracts;
|
|
using Socialize.Api.Infrastructure.Observability;
|
|
|
|
namespace Socialize.Api.Infrastructure.Emailer.Services;
|
|
|
|
internal class LoggerEmailSender(
|
|
ILogger<IEmailSender> logger,
|
|
SocializeMetrics metrics)
|
|
: IEmailSender
|
|
{
|
|
private static readonly Action<ILogger, string, string, string, string, Exception?> LogDevelopmentEmail =
|
|
LoggerMessage.Define<string, string, string, string>(
|
|
LogLevel.Information,
|
|
new EventId(1, nameof(SendEmailAsync)),
|
|
"Development email to {Email} with subject {Subject}:{NewLine}{Message}");
|
|
|
|
public Task SendEmailAsync(string email, string subject, string message)
|
|
{
|
|
LogDevelopmentEmail(logger, email, subject, Environment.NewLine, message, null);
|
|
metrics.RecordEmailDelivery("logger", true);
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
}
|