diff --git a/src/NzbDrone.Core/HealthCheck/Checks/SlackUrlCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/SlackUrlCheck.cs new file mode 100644 index 000000000..22f94dd4e --- /dev/null +++ b/src/NzbDrone.Core/HealthCheck/Checks/SlackUrlCheck.cs @@ -0,0 +1,39 @@ +using System.Linq; +using NzbDrone.Common.Extensions; +using NzbDrone.Core.Localization; +using NzbDrone.Core.Notifications; +using NzbDrone.Core.Notifications.Slack; +using NzbDrone.Core.ThingiProvider.Events; + +namespace NzbDrone.Core.HealthCheck.Checks +{ + [CheckOn(typeof(ProviderUpdatedEvent))] + [CheckOn(typeof(ProviderDeletedEvent))] + [CheckOn(typeof(ProviderStatusChangedEvent))] + public class SlackUrlCheck : HealthCheckBase + { + private readonly INotificationFactory _notificationFactory; + + public SlackUrlCheck(INotificationFactory notificationFactory, ILocalizationService localizationService) + : base(localizationService) + { + _notificationFactory = notificationFactory; + } + + public override HealthCheck Check() + { + var discordSlackNotifications = _notificationFactory.GetAvailableProviders().Where(n => n.ConfigContract.Equals("SlackSettings") && (n.Definition.Settings as SlackSettings).WebHookUrl.Contains("discord")); + + if (discordSlackNotifications.Empty()) + { + return new HealthCheck(GetType()); + } + + return new HealthCheck(GetType(), + HealthCheckResult.Warning, + string.Format(_localizationService.GetLocalizedString("DiscordUrlInSlackNotification"), + string.Join(", ", discordSlackNotifications.Select(n => n.Name))), + "#discord-as-slack-notification"); + } + } +} diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index cedcacf16..3420c1cd4 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -230,6 +230,7 @@ "DigitalRelease": "Digital Release", "Disabled": "Disabled", "Discord": "Discord", + "DiscordUrlInSlackNotification": "You have a Discord notification setup as a Slack notification. Set this up as a Discord notification for better functionality. The effected notifications are: {0}", "Discover": "Discover", "DiskSpace": "Disk Space", "Docker": "Docker",