diff --git a/src/Umbraco.Core/DateTimeExtensions.cs b/src/Umbraco.Core/DateTimeExtensions.cs index 6a127f152d..6e2676ac72 100644 --- a/src/Umbraco.Core/DateTimeExtensions.cs +++ b/src/Umbraco.Core/DateTimeExtensions.cs @@ -47,7 +47,7 @@ namespace Umbraco.Core /// Calculates the number of minutes from a date time, on a rolling daily basis (so if /// date time is before the time, calculate onto next day) /// - /// Date to start from + /// Date to start from /// Time to compare against (in Hmm form, e.g. 330, 2200) /// public static int PeriodicMinutesFrom(this DateTime fromDateTime, string scheduledTime) diff --git a/src/Umbraco.Web.UI/config/HealthChecks.Release.config b/src/Umbraco.Web.UI/config/HealthChecks.Release.config index 65ab6a2d53..69324bf513 100644 --- a/src/Umbraco.Web.UI/config/HealthChecks.Release.config +++ b/src/Umbraco.Web.UI/config/HealthChecks.Release.config @@ -16,7 +16,6 @@ https://our.umbraco.org/documentation/reference/config/healthchecks diff --git a/src/Umbraco.Web.UI/config/HealthChecks.config b/src/Umbraco.Web.UI/config/HealthChecks.config index 8de72cdcf1..eb35812d83 100644 --- a/src/Umbraco.Web.UI/config/HealthChecks.config +++ b/src/Umbraco.Web.UI/config/HealthChecks.config @@ -11,12 +11,11 @@ https://our.umbraco.org/documentation/reference/config/healthchecks - + - + - - + @@ -24,6 +23,4 @@ https://our.umbraco.org/documentation/reference/config/healthchecks - - - + \ No newline at end of file diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml index 0242523b62..39fc8a112b 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en.xml @@ -1772,6 +1772,8 @@ To manage your website, simply open the Umbraco back office and start adding con %0%.]]> %0%.]]> +

Results of the scheduled Umbraco Health Checks run on %0% at %1% are as follows:

%2%]]>
+ Umbraco Health Check Status Disable URL tracker diff --git a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml index 5ac74f2825..e256f604b4 100644 --- a/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/umbraco/config/lang/en_us.xml @@ -1699,6 +1699,8 @@ To manage your website, simply open the Umbraco back office and start adding con %0%.]]> %0%.]]> +

Results of the scheduled Umbraco Health Checks run on %0% at %1% are as follows:

%2%]]>
+ Umbraco Health Check Status Disable URL tracker diff --git a/src/Umbraco.Web/HealthCheck/NotificationMethods/EmailNotificationMethod.cs b/src/Umbraco.Web/HealthCheck/NotificationMethods/EmailNotificationMethod.cs index 3e5e03da06..bfce87fde0 100644 --- a/src/Umbraco.Web/HealthCheck/NotificationMethods/EmailNotificationMethod.cs +++ b/src/Umbraco.Web/HealthCheck/NotificationMethods/EmailNotificationMethod.cs @@ -1,25 +1,51 @@ using System; using System.Net.Mail; using System.Threading.Tasks; +using Umbraco.Core; +using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.HealthChecks; +using Umbraco.Core.Services; namespace Umbraco.Web.HealthCheck.NotificationMethods { [HealthCheckNotificationMethod("email")] public class EmailNotificationMethod : NotificationMethodBase, IHealthCheckNotificatationMethod { + private readonly ILocalizedTextService _textService; + + /// + /// Default constructor which is used in the provider model + /// + /// + /// + /// + /// public EmailNotificationMethod(bool enabled, bool failureOnly, HealthCheckNotificationVerbosity verbosity, - string recipientEmail, string subject) + string recipientEmail) + : this(enabled, failureOnly, verbosity, recipientEmail, ApplicationContext.Current.Services.TextService) + { + } + + /// + /// Constructor that could be used for testing + /// + /// + /// + /// + /// + /// + internal EmailNotificationMethod(bool enabled, bool failureOnly, HealthCheckNotificationVerbosity verbosity, + string recipientEmail, ILocalizedTextService textService) : base(enabled, failureOnly, verbosity) { + if (textService == null) throw new ArgumentNullException("textService"); + if (string.IsNullOrWhiteSpace(recipientEmail)) throw new ArgumentException("Value cannot be null or whitespace.", "recipientEmail"); + _textService = textService; RecipientEmail = recipientEmail; - Subject = subject; Verbosity = verbosity; } - public string RecipientEmail { get; private set; } - - public string Subject { get; private set; } + public string RecipientEmail { get; private set; } public async Task SendAsync(HealthCheckResults results) { @@ -33,20 +59,33 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods return; } - using (var client = new SmtpClient()) - using (var mailMessage = new MailMessage()) + var message = _textService.Localize("healthcheck/scheduledHealthCheckEmailBody", new[] { - mailMessage.To.Add(RecipientEmail); - mailMessage.Body = - string.Format( - "

Results of the scheduled Umbraco Health Checks run on {0} at {1} are as follows:

{2}", - DateTime.Now.ToShortDateString(), - DateTime.Now.ToShortTimeString(), - results.ResultsAsHtml(Verbosity)); - mailMessage.Subject = string.IsNullOrEmpty(Subject) ? "Umbraco Health Check Status" : Subject; - mailMessage.IsBodyHtml = true; + DateTime.Now.ToShortDateString(), + DateTime.Now.ToShortTimeString(), + results.ResultsAsHtml(Verbosity) + }); - await client.SendMailAsync(mailMessage); + var subject = _textService.Localize("healthcheck/scheduledHealthCheckEmailSubject"); + + using (var client = new SmtpClient()) + using (var mailMessage = new MailMessage(UmbracoConfig.For.UmbracoSettings().Content.NotificationEmailAddress, + RecipientEmail, + string.IsNullOrEmpty(subject) ? "Umbraco Health Check Status" : subject, + message) + { + IsBodyHtml = message.IsNullOrWhiteSpace() == false + && message.Contains("<") && message.Contains("