mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-18 21:35:51 -04:00
783878be1e
(cherry picked from commit a22f598b0c129110f2a3b663e9b40c84f3a1f02b) Closes #8615
41 lines
1.5 KiB
C#
41 lines
1.5 KiB
C#
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<INotificationFactory>))]
|
|
[CheckOn(typeof(ProviderDeletedEvent<INotificationFactory>))]
|
|
[CheckOn(typeof(ProviderStatusChangedEvent<INotificationFactory>))]
|
|
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") && ((SlackSettings)n.Definition.Settings).WebHookUrl.Contains("discord"))
|
|
.ToList();
|
|
|
|
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");
|
|
}
|
|
}
|
|
}
|