From 27e871656e999c02e777099f8b101c627fdd33f8 Mon Sep 17 00:00:00 2001 From: bakerboy448 <55419169+bakerboy448@users.noreply.github.com> Date: Mon, 3 May 2021 16:14:06 -0500 Subject: [PATCH] New: DiscordNotifier is now Notifiarr (#6263) [common] --- .../CleanseLogMessageFixture.cs | 2 +- .../Migration/195_update_notifiarr.cs | 15 +++++++++++ .../DiscordNotifierException.cs | 18 ------------- .../Notifiarr.cs} | 12 ++++----- .../Notifiarr/NotifiarrException.cs | 18 +++++++++++++ .../NotifiarrProxy.cs} | 26 +++++++++---------- .../NotifiarrSettings.cs} | 12 ++++----- 7 files changed, 59 insertions(+), 44 deletions(-) create mode 100644 src/NzbDrone.Core/Datastore/Migration/195_update_notifiarr.cs delete mode 100644 src/NzbDrone.Core/Notifications/DiscordNotifier/DiscordNotifierException.cs rename src/NzbDrone.Core/Notifications/{DiscordNotifier/DiscordNotifier.cs => Notifiarr/Notifiarr.cs} (95%) create mode 100644 src/NzbDrone.Core/Notifications/Notifiarr/NotifiarrException.cs rename src/NzbDrone.Core/Notifications/{DiscordNotifier/DiscordNotifierProxy.cs => Notifiarr/NotifiarrProxy.cs} (73%) rename src/NzbDrone.Core/Notifications/{DiscordNotifier/DiscordNotifierSettings.cs => Notifiarr/NotifiarrSettings.cs} (56%) diff --git a/src/NzbDrone.Common.Test/InstrumentationTests/CleanseLogMessageFixture.cs b/src/NzbDrone.Common.Test/InstrumentationTests/CleanseLogMessageFixture.cs index d2b7991bc..0b9b3b30e 100644 --- a/src/NzbDrone.Common.Test/InstrumentationTests/CleanseLogMessageFixture.cs +++ b/src/NzbDrone.Common.Test/InstrumentationTests/CleanseLogMessageFixture.cs @@ -61,7 +61,7 @@ public class CleanseLogMessageFixture [TestCase(@"OutputPath=/home/mySecret/Downloads")] [TestCase("Hardlinking episode file: /home/mySecret/Downloads to /media/abc.mkv")] [TestCase("Hardlink '/home/mySecret/Downloads/abs.mkv' to '/media/abc.mkv' failed.")] - [TestCase("https://discordnotifier.com/notifier.php: api=1234530f-422f-4aac-b6b3-01233210aaaa&radarr_health_issue_message=Download")] + [TestCase("https://notifiarr.com/notifier.php: api=1234530f-422f-4aac-b6b3-01233210aaaa&radarr_health_issue_message=Download")] // Announce URLs (passkeys) Magnet & Tracker [TestCase(@"magnet_uri"":""magnet:?xt=urn:btih:9pr04sgkillroyimaveql2tyu8xyui&dn=&tr=https%3a%2f%2fxxx.yyy%2f9pr04sg601233210imaveql2tyu8xyui%2fannounce""}")] diff --git a/src/NzbDrone.Core/Datastore/Migration/195_update_notifiarr.cs b/src/NzbDrone.Core/Datastore/Migration/195_update_notifiarr.cs new file mode 100644 index 000000000..b2c455271 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/195_update_notifiarr.cs @@ -0,0 +1,15 @@ +using FluentMigrator; +using Newtonsoft.Json.Linq; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(195)] + public class update_notifiarr : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Execute.Sql("UPDATE Notifications SET Implementation = Replace(Implementation, 'DiscordNotifier', 'Notifiarr'),ConfigContract = Replace(ConfigContract, 'DiscordNotifierSettings', 'NotifiarrSettings') WHERE Implementation = 'DiscordNotifier';"); + } + } +} diff --git a/src/NzbDrone.Core/Notifications/DiscordNotifier/DiscordNotifierException.cs b/src/NzbDrone.Core/Notifications/DiscordNotifier/DiscordNotifierException.cs deleted file mode 100644 index e41b776da..000000000 --- a/src/NzbDrone.Core/Notifications/DiscordNotifier/DiscordNotifierException.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using NzbDrone.Common.Exceptions; - -namespace NzbDrone.Core.Notifications.DiscordNotifier -{ - public class DiscordNotifierException : NzbDroneException - { - public DiscordNotifierException(string message) - : base(message) - { - } - - public DiscordNotifierException(string message, Exception innerException, params object[] args) - : base(message, innerException, args) - { - } - } -} diff --git a/src/NzbDrone.Core/Notifications/DiscordNotifier/DiscordNotifier.cs b/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs similarity index 95% rename from src/NzbDrone.Core/Notifications/DiscordNotifier/DiscordNotifier.cs rename to src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs index b9a18f860..5b8ef893b 100644 --- a/src/NzbDrone.Core/Notifications/DiscordNotifier/DiscordNotifier.cs +++ b/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs @@ -6,19 +6,19 @@ using FluentValidation.Results; using NzbDrone.Common.Extensions; -namespace NzbDrone.Core.Notifications.DiscordNotifier +namespace NzbDrone.Core.Notifications.Notifiarr { - public class DiscordNotifier : NotificationBase + public class Notifiarr : NotificationBase { - private readonly IDiscordNotifierProxy _proxy; + private readonly INotifiarrProxy _proxy; - public DiscordNotifier(IDiscordNotifierProxy proxy) + public Notifiarr(INotifiarrProxy proxy) { _proxy = proxy; } - public override string Link => "https://discordnotifier.com"; - public override string Name => "DiscordNotifier.com"; + public override string Link => "https://notifiarr.com"; + public override string Name => "Notifiarr"; public override void OnGrab(GrabMessage message) { diff --git a/src/NzbDrone.Core/Notifications/Notifiarr/NotifiarrException.cs b/src/NzbDrone.Core/Notifications/Notifiarr/NotifiarrException.cs new file mode 100644 index 000000000..283edda13 --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Notifiarr/NotifiarrException.cs @@ -0,0 +1,18 @@ +using System; +using NzbDrone.Common.Exceptions; + +namespace NzbDrone.Core.Notifications.Notifiarr +{ + public class NotifiarrException : NzbDroneException + { + public NotifiarrException(string message) + : base(message) + { + } + + public NotifiarrException(string message, Exception innerException, params object[] args) + : base(message, innerException, args) + { + } + } +} diff --git a/src/NzbDrone.Core/Notifications/DiscordNotifier/DiscordNotifierProxy.cs b/src/NzbDrone.Core/Notifications/Notifiarr/NotifiarrProxy.cs similarity index 73% rename from src/NzbDrone.Core/Notifications/DiscordNotifier/DiscordNotifierProxy.cs rename to src/NzbDrone.Core/Notifications/Notifiarr/NotifiarrProxy.cs index 015ed469e..71a7c44e9 100644 --- a/src/NzbDrone.Core/Notifications/DiscordNotifier/DiscordNotifierProxy.cs +++ b/src/NzbDrone.Core/Notifications/Notifiarr/NotifiarrProxy.cs @@ -7,40 +7,40 @@ using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Http; -namespace NzbDrone.Core.Notifications.DiscordNotifier +namespace NzbDrone.Core.Notifications.Notifiarr { - public interface IDiscordNotifierProxy + public interface INotifiarrProxy { - void SendNotification(StringDictionary message, DiscordNotifierSettings settings); - ValidationFailure Test(DiscordNotifierSettings settings); + void SendNotification(StringDictionary message, NotifiarrSettings settings); + ValidationFailure Test(NotifiarrSettings settings); } - public class DiscordNotifierProxy : IDiscordNotifierProxy + public class NotifiarrProxy : INotifiarrProxy { - private const string URL = "https://discordnotifier.com/notifier.php"; + private const string URL = "https://notifiarr.com/notifier.php"; private readonly IHttpClient _httpClient; private readonly Logger _logger; - public DiscordNotifierProxy(IHttpClient httpClient, Logger logger) + public NotifiarrProxy(IHttpClient httpClient, Logger logger) { _httpClient = httpClient; _logger = logger; } - public void SendNotification(StringDictionary message, DiscordNotifierSettings settings) + public void SendNotification(StringDictionary message, NotifiarrSettings settings) { try { ProcessNotification(message, settings); } - catch (DiscordNotifierException ex) + catch (NotifiarrException ex) { _logger.Error(ex, "Unable to send notification"); - throw new DiscordNotifierException("Unable to send notification"); + throw new NotifiarrException("Unable to send notification"); } } - public ValidationFailure Test(DiscordNotifierSettings settings) + public ValidationFailure Test(NotifiarrSettings settings) { try { @@ -68,7 +68,7 @@ public ValidationFailure Test(DiscordNotifierSettings settings) } } - private void ProcessNotification(StringDictionary message, DiscordNotifierSettings settings) + private void ProcessNotification(StringDictionary message, NotifiarrSettings settings) { try { @@ -92,7 +92,7 @@ private void ProcessNotification(StringDictionary message, DiscordNotifierSettin throw; } - throw new DiscordNotifierException("Unable to send notification", ex); + throw new NotifiarrException("Unable to send notification", ex); } } } diff --git a/src/NzbDrone.Core/Notifications/DiscordNotifier/DiscordNotifierSettings.cs b/src/NzbDrone.Core/Notifications/Notifiarr/NotifiarrSettings.cs similarity index 56% rename from src/NzbDrone.Core/Notifications/DiscordNotifier/DiscordNotifierSettings.cs rename to src/NzbDrone.Core/Notifications/Notifiarr/NotifiarrSettings.cs index bfe59190c..1a8bb06c9 100644 --- a/src/NzbDrone.Core/Notifications/DiscordNotifier/DiscordNotifierSettings.cs +++ b/src/NzbDrone.Core/Notifications/Notifiarr/NotifiarrSettings.cs @@ -3,21 +3,21 @@ using NzbDrone.Core.ThingiProvider; using NzbDrone.Core.Validation; -namespace NzbDrone.Core.Notifications.DiscordNotifier +namespace NzbDrone.Core.Notifications.Notifiarr { - public class DiscordNotifierSettingsValidator : AbstractValidator + public class NotifiarrSettingsValidator : AbstractValidator { - public DiscordNotifierSettingsValidator() + public NotifiarrSettingsValidator() { RuleFor(c => c.APIKey).NotEmpty(); } } - public class DiscordNotifierSettings : IProviderConfig + public class NotifiarrSettings : IProviderConfig { - private static readonly DiscordNotifierSettingsValidator Validator = new DiscordNotifierSettingsValidator(); + private static readonly NotifiarrSettingsValidator Validator = new NotifiarrSettingsValidator(); - [FieldDefinition(0, Label = "API Key", Privacy = PrivacyLevel.ApiKey, HelpText = "Your API key from your profile", HelpLink = "https://discordnotifier.com")] + [FieldDefinition(0, Label = "API Key", Privacy = PrivacyLevel.ApiKey, HelpText = "Your API key from your profile", HelpLink = "https://notifiarr.com")] public string APIKey { get; set; } public NzbDroneValidationResult Validate()