mirror of
https://github.com/Radarr/Radarr
synced 2025-02-23 23:01:10 +00:00
New: Health check for Discord notifications setup as Slack
This commit is contained in:
parent
5ed034320e
commit
eecd746f51
2 changed files with 40 additions and 0 deletions
39
src/NzbDrone.Core/HealthCheck/Checks/SlackUrlCheck.cs
Normal file
39
src/NzbDrone.Core/HealthCheck/Checks/SlackUrlCheck.cs
Normal file
|
@ -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<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") && (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");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue