mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-22 22:15:17 -04:00
Provider testing improvements
New: Test button for indexers in UI Fixed: Testing download clients shows error messages in UI Fixed: Testing notifications shows error messages in UI
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Xml.Linq;
|
||||
using FluentValidation.Results;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Exceptions;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using RestSharp;
|
||||
using NzbDrone.Core.Rest;
|
||||
|
||||
@@ -12,12 +13,19 @@ namespace NzbDrone.Core.Notifications.NotifyMyAndroid
|
||||
public interface INotifyMyAndroidProxy
|
||||
{
|
||||
void SendNotification(string title, string message, string apiKye, NotifyMyAndroidPriority priority);
|
||||
ValidationFailure Test(NotifyMyAndroidSettings settings);
|
||||
}
|
||||
|
||||
public class NotifyMyAndroidProxy : INotifyMyAndroidProxy, IExecute<TestNotifyMyAndroidCommand>
|
||||
public class NotifyMyAndroidProxy : INotifyMyAndroidProxy
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
private const string URL = "https://www.notifymyandroid.com/publicapi";
|
||||
|
||||
public NotifyMyAndroidProxy(Logger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void SendNotification(string title, string message, string apiKey, NotifyMyAndroidPriority priority)
|
||||
{
|
||||
var client = new RestClient(URL);
|
||||
@@ -56,12 +64,22 @@ namespace NzbDrone.Core.Notifications.NotifyMyAndroid
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(TestNotifyMyAndroidCommand message)
|
||||
public ValidationFailure Test(NotifyMyAndroidSettings settings)
|
||||
{
|
||||
const string title = "Test Notification";
|
||||
const string body = "This is a test message from NzbDrone";
|
||||
Verify(message.ApiKey);
|
||||
SendNotification(title, body, message.ApiKey, (NotifyMyAndroidPriority)message.Priority);
|
||||
try
|
||||
{
|
||||
const string title = "Test Notification";
|
||||
const string body = "This is a test message from NzbDrone";
|
||||
Verify(settings.ApiKey);
|
||||
SendNotification(title, body, settings.ApiKey, (NotifyMyAndroidPriority)settings.Priority);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Unable to send test message: " + ex.Message, ex);
|
||||
return new ValidationFailure("ApiKey", "Unable to send test message");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user