removed duplicated method
parent
b75793a08a
commit
826bee7db6
|
@ -5,7 +5,10 @@ namespace Correo.Abstractions.Extensions
|
|||
{
|
||||
public static class ModelExtensions
|
||||
{
|
||||
public static string Log(this IEnumerable<EmailMessage.MailAddress> addresses)
|
||||
private static string Log(this IEnumerable<EmailMessage.MailAddress> addresses)
|
||||
=> addresses != null ? string.Join(',', addresses.Select(z => z.Address)) : string.Empty;
|
||||
|
||||
public static string Log(this EmailMessage message)
|
||||
=> $"Email sent: Subject: {message.Subject}; From: {message.From.Address}; To: {message.To.Log()}; Cc: {message.Cc.Log()}; Bcc: {message.Bcc.Log()};";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,17 +47,14 @@ namespace Correo.MailKit
|
|||
{
|
||||
var mailMessage = message.ToMailMessage();
|
||||
_smtpClient.Send(mailMessage);
|
||||
Log(message);
|
||||
_logger.LogInformation(message.Log());
|
||||
}
|
||||
|
||||
public async Task SendEmailAsync(EmailMessage message, CancellationToken token = default)
|
||||
{
|
||||
var mailMessage = message.ToMailMessage();
|
||||
await _smtpClient.SendAsync(mailMessage, token);
|
||||
Log(message);
|
||||
}
|
||||
|
||||
private void Log(EmailMessage message)
|
||||
=> _logger.LogInformation($"Email sent: Subject: {message.Subject}; From: {message.From.Address}; To: {message.To.Log()}; Cc: {message.Cc.Log()}; Bcc: {message.Bcc.Log()};");
|
||||
_logger.LogInformation(message.Log());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,15 +65,12 @@ namespace Correo.Mailgun
|
|||
if (response.IsSuccessful)
|
||||
{
|
||||
_logger.LogInformation($"Mailgun response: {response.Data.Message} {response.Data.Id}");
|
||||
Log(message);
|
||||
_logger.LogInformation(message.Log());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Mailgun error: {response.Data.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void Log(EmailMessage message)
|
||||
=> _logger.LogInformation($"Email sent: Subject: {message.Subject}; From: {message.From.Address}; To: {message.To.Log()}; Cc: {message.Cc.Log()}; Bcc: {message.Bcc.Log()};");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,17 +49,14 @@ namespace Correo.NetSmtpClient
|
|||
{
|
||||
var mailMessage = message.ToMailMessage();
|
||||
_smtpClient.Send(mailMessage);
|
||||
Log(message);
|
||||
_logger.LogInformation(message.Log());
|
||||
}
|
||||
|
||||
public async Task SendEmailAsync(EmailMessage message, CancellationToken token = default)
|
||||
{
|
||||
var mailMessage = message.ToMailMessage();
|
||||
await _smtpClient.SendMailAsync(mailMessage, token);
|
||||
Log(message);
|
||||
}
|
||||
|
||||
private void Log(EmailMessage message)
|
||||
=> _logger.LogInformation($"Email sent: Subject: {message.Subject}; From: {message.From.Address}; To: {message.To.Log()}; Cc: {message.Cc.Log()}; Bcc: {message.Bcc.Log()};");
|
||||
_logger.LogInformation(message.Log());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace Correo.SendGrid
|
|||
var mailMessage = message.ToSendGridMessage();
|
||||
var response = await _client.SendEmailAsync(mailMessage, token);
|
||||
if (response.IsSuccessStatusCode)
|
||||
Log(message);
|
||||
_logger.LogInformation(message.Log());
|
||||
else
|
||||
{
|
||||
var body = await response.DeserializeResponseBodyAsync();
|
||||
|
@ -52,8 +52,5 @@ namespace Correo.SendGrid
|
|||
throw new Exception(response.StatusCode.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void Log(EmailMessage message)
|
||||
=> _logger.LogInformation($"Email sent: Subject: {message.Subject}; From: {message.From.Address}; To: {message.To.Log()}; Cc: {message.Cc.Log()}; Bcc: {message.Bcc.Log()};");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue