2016-06-13 17:42:05 +02:00
|
|
|
|
using System.Collections.Generic;
|
2020-09-21 13:04:57 +02:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2020-10-21 10:29:25 +01:00
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
|
using Umbraco.Core.Configuration.Models;
|
2016-06-13 17:42:05 +02:00
|
|
|
|
using Umbraco.Core.Services;
|
|
|
|
|
|
|
2020-10-21 10:29:25 +01:00
|
|
|
|
namespace Umbraco.Core.HealthCheck.Checks.Configuration
|
2016-06-13 17:42:05 +02:00
|
|
|
|
{
|
|
|
|
|
|
[HealthCheck("3E2F7B14-4B41-452B-9A30-E67FBC8E1206", "Notification Email Settings",
|
|
|
|
|
|
Description = "If notifications are used, the 'from' email address should be specified and changed from the default value.",
|
|
|
|
|
|
Group = "Configuration")]
|
2020-10-21 10:29:25 +01:00
|
|
|
|
public class NotificationEmailCheck : AbstractSettingsCheck
|
2016-06-13 17:42:05 +02:00
|
|
|
|
{
|
2020-10-21 10:29:25 +01:00
|
|
|
|
private readonly IOptionsMonitor<ContentSettings> _contentSettings;
|
2016-06-13 17:42:05 +02:00
|
|
|
|
private const string DefaultFromEmail = "your@email.here";
|
|
|
|
|
|
|
2020-10-21 10:29:25 +01:00
|
|
|
|
public NotificationEmailCheck(ILocalizedTextService textService, ILoggerFactory loggerFactory, IOptionsMonitor<ContentSettings> contentSettings)
|
|
|
|
|
|
: base(textService, loggerFactory)
|
|
|
|
|
|
{
|
|
|
|
|
|
_contentSettings = contentSettings;
|
|
|
|
|
|
}
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2020-10-21 10:29:25 +01:00
|
|
|
|
public override string ItemPath => Constants.Configuration.ConfigContentNotificationsEmail;
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2016-09-01 19:06:08 +02:00
|
|
|
|
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldNotEqual;
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2016-09-01 19:06:08 +02:00
|
|
|
|
public override IEnumerable<AcceptableConfiguration> Values => new List<AcceptableConfiguration>
|
2016-06-13 17:42:05 +02:00
|
|
|
|
{
|
2016-09-01 19:06:08 +02:00
|
|
|
|
new AcceptableConfiguration { IsRecommended = false, Value = DefaultFromEmail }
|
|
|
|
|
|
};
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2020-10-21 10:29:25 +01:00
|
|
|
|
public override string CurrentValue => _contentSettings.CurrentValue.Notifications.Email;
|
|
|
|
|
|
|
|
|
|
|
|
public override string CheckSuccessMessage => TextService.Localize("healthcheck/notificationEmailsCheckSuccessMessage", new[] { CurrentValue });
|
2016-09-01 19:06:08 +02:00
|
|
|
|
|
|
|
|
|
|
public override string CheckErrorMessage => TextService.Localize("healthcheck/notificationEmailsCheckErrorMessage", new[] { DefaultFromEmail });
|
2020-10-21 10:29:25 +01:00
|
|
|
|
|
2016-06-13 17:42:05 +02:00
|
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|