// Copyright (c) Umbraco.
// See LICENSE for more details.
using System.Collections.Generic;
using Microsoft.Extensions.Options;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Services;
namespace Umbraco.Core.HealthChecks.Checks.Configuration
{
///
/// Health check for the recommended production configuration for Notification Email.
///
[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")]
public class NotificationEmailCheck : AbstractSettingsCheck
{
private readonly IOptionsMonitor _contentSettings;
private const string DefaultFromEmail = "your@email.here";
///
/// Initializes a new instance of the class.
///
public NotificationEmailCheck(
ILocalizedTextService textService,
IOptionsMonitor contentSettings)
: base(textService) =>
_contentSettings = contentSettings;
///
public override string ItemPath => Constants.Configuration.ConfigContentNotificationsEmail;
///
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldNotEqual;
///
public override IEnumerable Values => new List
{
new AcceptableConfiguration { IsRecommended = false, Value = DefaultFromEmail }
};
///
public override string CurrentValue => _contentSettings.CurrentValue.Notifications.Email;
///
public override string CheckSuccessMessage => LocalizedTextService.Localize("healthcheck/notificationEmailsCheckSuccessMessage", new[] { CurrentValue });
///
public override string CheckErrorMessage => LocalizedTextService.Localize("healthcheck/notificationEmailsCheckErrorMessage", new[] { DefaultFromEmail });
///
public override string ReadMoreLink => Constants.HealthChecks.DocumentationLinks.Configuration.NotificationEmailCheck;
}
}