Merge pull request #10998 from umbraco/v9/bugfix/email-sending-metadata
Updates email sender to have some metadata
This commit is contained in:
@@ -59,6 +59,15 @@ namespace Umbraco.Cms.Core
|
||||
public const string ActionToken = "action";
|
||||
public const string AreaToken = "area";
|
||||
}
|
||||
|
||||
public static class EmailTypes
|
||||
{
|
||||
public const string HealthCheck = "HealthCheck";
|
||||
public const string Notification = "Notification";
|
||||
public const string PasswordReset = "PasswordReset";
|
||||
public const string TwoFactorAuth = "2FA";
|
||||
public const string UserInvite = "UserInvite";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
@@ -74,7 +74,7 @@ namespace Umbraco.Cms.Core.HealthChecks.NotificationMethods
|
||||
|
||||
|
||||
var mailMessage = CreateMailMessage(subject, message);
|
||||
await _emailSender.SendAsync(mailMessage);
|
||||
await _emailSender.SendAsync(mailMessage, Constants.Web.EmailTypes.HealthCheck);
|
||||
}
|
||||
|
||||
private EmailMessage CreateMailMessage(string subject, string message)
|
||||
|
||||
@@ -8,9 +8,9 @@ namespace Umbraco.Cms.Core.Mail
|
||||
/// </summary>
|
||||
public interface IEmailSender
|
||||
{
|
||||
Task SendAsync(EmailMessage message);
|
||||
Task SendAsync(EmailMessage message, string emailType);
|
||||
|
||||
Task SendAsync(EmailMessage message, bool enableNotification);
|
||||
Task SendAsync(EmailMessage message, string emailType, bool enableNotification);
|
||||
|
||||
bool CanSendRequiredEmail();
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ namespace Umbraco.Cms.Core.Mail
|
||||
{
|
||||
internal class NotImplementedEmailSender : IEmailSender
|
||||
{
|
||||
public Task SendAsync(EmailMessage message)
|
||||
public Task SendAsync(EmailMessage message, string emailType)
|
||||
=> throw new NotImplementedException("To send an Email ensure IEmailSender is implemented with a custom implementation");
|
||||
|
||||
public Task SendAsync(EmailMessage message, bool enableNotification) =>
|
||||
public Task SendAsync(EmailMessage message, string emailType, bool enableNotification) =>
|
||||
throw new NotImplementedException(
|
||||
"To send an Email ensure IEmailSender is implemented with a custom implementation");
|
||||
|
||||
|
||||
@@ -4,10 +4,19 @@ namespace Umbraco.Cms.Core.Notifications
|
||||
{
|
||||
public class SendEmailNotification : INotification
|
||||
{
|
||||
public SendEmailNotification(NotificationEmailModel message) => Message = message;
|
||||
public SendEmailNotification(NotificationEmailModel message, string emailType)
|
||||
{
|
||||
Message = message;
|
||||
EmailType = emailType;
|
||||
}
|
||||
|
||||
public NotificationEmailModel Message { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Some metadata about the email which can be used by handlers to determine if they should handle the email or not
|
||||
/// </summary>
|
||||
public string EmailType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Call to tell Umbraco that the email sending is handled.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user