Revert "Temp8 tinymce"

This commit is contained in:
Warren Buckley
2018-11-22 14:05:51 +00:00
committed by GitHub
parent 2a0748fc1e
commit 54a2aa00a7
6677 changed files with 646351 additions and 410535 deletions

View File

@@ -1,35 +1,52 @@
using System;
using System.Net.Mail;
using System.Threading;
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
public class EmailNotificationMethod : NotificationMethodBase, IHealthCheckNotificatationMethod
{
private readonly ILocalizedTextService _textService;
public EmailNotificationMethod(ILocalizedTextService textService)
/// <summary>
/// Default constructor which is used in the provider model
/// </summary>
/// <param name="enabled"></param>
/// <param name="failureOnly"></param>
/// <param name="verbosity"></param>
/// <param name="recipientEmail"></param>
public EmailNotificationMethod(bool enabled, bool failureOnly, HealthCheckNotificationVerbosity verbosity,
string recipientEmail)
: this(enabled, failureOnly, verbosity, recipientEmail, ApplicationContext.Current.Services.TextService)
{
var recipientEmail = Settings["recipientEmail"]?.Value;
if (string.IsNullOrWhiteSpace(recipientEmail))
{
Enabled = false;
return;
}
RecipientEmail = recipientEmail;
_textService = textService ?? throw new ArgumentNullException(nameof(textService));
}
public string RecipientEmail { get; }
/// <summary>
/// Constructor that could be used for testing
/// </summary>
/// <param name="enabled"></param>
/// <param name="failureOnly"></param>
/// <param name="verbosity"></param>
/// <param name="recipientEmail"></param>
/// <param name="textService"></param>
internal EmailNotificationMethod(bool enabled, bool failureOnly, HealthCheckNotificationVerbosity verbosity,
string recipientEmail, ILocalizedTextService textService)
: base(enabled, failureOnly, verbosity)
{
if (textService == null) throw new ArgumentNullException("textService");
_textService = textService;
RecipientEmail = recipientEmail;
Verbosity = verbosity;
}
public override async Task SendAsync(HealthCheckResults results, CancellationToken token)
public string RecipientEmail { get; private set; }
public async Task SendAsync(HealthCheckResults results)
{
if (ShouldSend(results) == false)
{
@@ -51,23 +68,17 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
var subject = _textService.Localize("healthcheck/scheduledHealthCheckEmailSubject");
var mailSender = new EmailSender();
using (var mailMessage = CreateMailMessage(subject, message))
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("</")
})
{
await mailSender.SendAsync(mailMessage);
}
}
private MailMessage CreateMailMessage(string subject, string message)
{
var to = UmbracoConfig.For.UmbracoSettings().Content.NotificationEmailAddress;
if (string.IsNullOrWhiteSpace(subject))
subject = "Umbraco Health Check Status";
return new MailMessage(to, RecipientEmail, subject, message)
{
IsBodyHtml = message.IsNullOrWhiteSpace() == false && message.Contains("<") && message.Contains("</")
};
}
}
}

View File

@@ -0,0 +1,10 @@
using System.Threading.Tasks;
namespace Umbraco.Web.HealthCheck.NotificationMethods
{
public interface IHealthCheckNotificatationMethod
{
bool Enabled { get; }
Task SendAsync(HealthCheckResults results);
}
}

View File

@@ -1,11 +0,0 @@
using System.Threading;
using System.Threading.Tasks;
namespace Umbraco.Web.HealthCheck.NotificationMethods
{
public interface IHealthCheckNotificationMethod
{
bool Enabled { get; }
Task SendAsync(HealthCheckResults results, CancellationToken token);
}
}

View File

@@ -1,37 +1,14 @@
using System.Collections.Generic;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.HealthChecks;
using Umbraco.Core.Configuration.HealthChecks;
namespace Umbraco.Web.HealthCheck.NotificationMethods
{
public abstract class NotificationMethodBase : IHealthCheckNotificationMethod
public abstract class NotificationMethodBase
{
protected NotificationMethodBase()
protected NotificationMethodBase(bool enabled, bool failureOnly, HealthCheckNotificationVerbosity verbosity)
{
var type = GetType();
var attribute = type.GetCustomAttribute<HealthCheckNotificationMethodAttribute>();
if (attribute == null)
{
Enabled = false;
return;
}
var healthCheckConfig = UmbracoConfig.For.HealthCheck();
var notificationMethods = healthCheckConfig.NotificationSettings.NotificationMethods;
var notificationMethod = notificationMethods[attribute.Alias];
if (notificationMethod == null)
{
Enabled = false;
return;
}
Enabled = notificationMethod.Enabled;
FailureOnly = notificationMethod.FailureOnly;
Verbosity = notificationMethod.Verbosity;
Settings = notificationMethod.Settings;
Enabled = enabled;
FailureOnly = failureOnly;
Verbosity = verbosity;
}
public bool Enabled { get; protected set; }
@@ -40,13 +17,19 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods
public HealthCheckNotificationVerbosity Verbosity { get; protected set; }
public IReadOnlyDictionary<string, INotificationMethodSettings> Settings { get; }
protected bool ShouldSend(HealthCheckResults results)
{
return Enabled && (!FailureOnly || !results.AllChecksSuccessful);
}
if (Enabled == false)
{
return false;
}
public abstract Task SendAsync(HealthCheckResults results, CancellationToken token);
if (FailureOnly && results.AllChecksSuccessful)
{
return false;
}
return true;
}
}
}