mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-21 22:04:31 -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:
@@ -1,18 +1,18 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Mail;
|
||||
using FluentValidation.Results;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using Omu.ValueInjecter;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Email
|
||||
{
|
||||
public interface IEmailService
|
||||
{
|
||||
void SendEmail(EmailSettings settings, string subject, string body, bool htmlBody = false);
|
||||
ValidationFailure Test(EmailSettings settings);
|
||||
}
|
||||
|
||||
public class EmailService : IEmailService, IExecute<TestEmailCommand>
|
||||
public class EmailService : IEmailService
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
|
||||
@@ -66,14 +66,21 @@ namespace NzbDrone.Core.Notifications.Email
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(TestEmailCommand message)
|
||||
public ValidationFailure Test(EmailSettings settings)
|
||||
{
|
||||
var settings = new EmailSettings();
|
||||
settings.InjectFrom(message);
|
||||
|
||||
const string body = "Success! You have properly configured your email notification settings";
|
||||
|
||||
SendEmail(settings, "NzbDrone - Test Notification", body);
|
||||
try
|
||||
{
|
||||
SendEmail(settings, "NzbDrone - Test Notification", body);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Unable to send test email: " + ex.Message, ex);
|
||||
return new ValidationFailure("Server", "Unable to send test email");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user