New: DiscordNotifier is now Notifiarr (#50)

* New: DiscordNotifier is now Notifiarr

* Fixed: Cleanse Notifiarr APIKey from logs

add download station test case
pull/61/head
bakerboy448 4 years ago committed by GitHub
parent 65f936c7c3
commit 2100587b5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -46,13 +46,17 @@ namespace NzbDrone.Common.Test.InstrumentationTests
[TestCase(@",{""download_location"": ""/home/mySecret/Downloads""}")]
[TestCase(@"auth.login(""mySecret"")")]
// Download Station
[TestCase(@"webapi/entry.cgi?api=(removed)&version=2&method=login&account=01233210&passwd=mySecret&format=sid&session=DownloadStation")]
// BroadcastheNet
[TestCase(@"method: ""getTorrents"", ""params"": [ ""mySecret"",")]
[TestCase(@"getTorrents(""mySecret"", [asdfasdf], 100, 0)")]
[TestCase(@"""DownloadURL"":""https:\/\/broadcasthe.net\/torrents.php?action=download&id=123&authkey=mySecret&torrent_pass=mySecret""")]
// Plex
[TestCase(@" http://localhost:32400/library/metadata/12345/refresh?X-Plex-Client-Identifier=1234530f-422f-4aac-b6b3-01233210aaaa&X-Plex-Product=Sonarr&X-Plex-Platform=Windows&X-Plex-Platform-Version=7&X-Plex-Device-Name=Sonarr&X-Plex-Version=3.0.3.833&X-Plex-Token=mySecret")]
// Notifiarr
[TestCase("https://notifiarr.com/notifier.php: api=1234530f-422f-4aac-b6b3-01233210aaaa&radarr_health_issue_message=Download")]
public void should_clean_message(string message)
{
var cleansedMessage = CleanseLogMessage.Cleanse(message);

@ -11,7 +11,7 @@ namespace NzbDrone.Common.Instrumentation
private static readonly Regex[] CleansingRules = new[]
{
// Url
new Regex(@"(?<=\?|&)(apikey|token|passkey|auth|authkey|user|uid|api|[a-z_]*apikey)=(?<secret>[^&=]+?)(?= |&|$)", RegexOptions.Compiled | RegexOptions.IgnoreCase),
new Regex(@"(?<=\?|&|: )(apikey|token|passkey|auth|authkey|user|uid|api|[a-z_]*apikey|account|passwd)=(?<secret>[^&=]+?)(?= |&|$)", RegexOptions.Compiled | RegexOptions.IgnoreCase),
new Regex(@"(?<=\?|&)[^=]*?(username|password)=(?<secret>[^&=]+?)(?= |&|$)", RegexOptions.Compiled | RegexOptions.IgnoreCase),
new Regex(@"torrentleech\.org/(?!rss)(?<secret>[0-9a-z]+)", RegexOptions.Compiled | RegexOptions.IgnoreCase),
new Regex(@"torrentleech\.org/rss/download/[0-9]+/(?<secret>[0-9a-z]+)", RegexOptions.Compiled | RegexOptions.IgnoreCase),

@ -0,0 +1,15 @@
using FluentMigrator;
using Newtonsoft.Json.Linq;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(5)]
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';");
}
}
}

@ -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)
{
}
}
}

@ -3,19 +3,19 @@ using System.Collections.Specialized;
using FluentValidation.Results;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Core.Notifications.DiscordNotifier
namespace NzbDrone.Core.Notifications.Notifiarr
{
public class DiscordNotifier : NotificationBase<DiscordNotifierSettings>
public class Notifiarr : NotificationBase<NotifiarrSettings>
{
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 => "Discord Notifier";
public override string Link => "https://notifiarr.com";
public override string Name => "Notifiarr";
public override void OnHealthIssue(HealthCheck.HealthCheck healthCheck)
{
var variables = new StringDictionary();

@ -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)
{
}
}
}

@ -5,40 +5,40 @@ using FluentValidation.Results;
using NLog;
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
{
@ -66,7 +66,7 @@ namespace NzbDrone.Core.Notifications.DiscordNotifier
}
}
private void ProcessNotification(StringDictionary message, DiscordNotifierSettings settings)
private void ProcessNotification(StringDictionary message, NotifiarrSettings settings)
{
try
{
@ -90,7 +90,7 @@ namespace NzbDrone.Core.Notifications.DiscordNotifier
throw;
}
throw new DiscordNotifierException("Unable to send notification", ex);
throw new NotifiarrException("Unable to send notification", ex);
}
}
}

@ -3,21 +3,21 @@ using NzbDrone.Core.Annotations;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.Notifications.DiscordNotifier
namespace NzbDrone.Core.Notifications.Notifiarr
{
public class DiscordNotifierSettingsValidator : AbstractValidator<DiscordNotifierSettings>
public class NotifiarrSettingsValidator : AbstractValidator<NotifiarrSettings>
{
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()
Loading…
Cancel
Save