mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-28 23:27:08 -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,15 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FluentValidation.Results;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Tv;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Email
|
||||
{
|
||||
public class Email : NotificationBase<EmailSettings>
|
||||
{
|
||||
private readonly IEmailService _smtpProvider;
|
||||
private readonly IEmailService _emailService;
|
||||
|
||||
public Email(IEmailService smtpProvider)
|
||||
public Email(IEmailService emailService)
|
||||
{
|
||||
_smtpProvider = smtpProvider;
|
||||
_emailService = emailService;
|
||||
}
|
||||
|
||||
public override string Link
|
||||
@@ -20,9 +23,9 @@ namespace NzbDrone.Core.Notifications.Email
|
||||
public override void OnGrab(string message)
|
||||
{
|
||||
const string subject = "NzbDrone [TV] - Grabbed";
|
||||
var body = String.Format("{0} sent to SABnzbd queue.", message);
|
||||
var body = String.Format("{0} sent to queue.", message);
|
||||
|
||||
_smtpProvider.SendEmail(Settings, subject, body);
|
||||
_emailService.SendEmail(Settings, subject, body);
|
||||
}
|
||||
|
||||
public override void OnDownload(DownloadMessage message)
|
||||
@@ -30,11 +33,20 @@ namespace NzbDrone.Core.Notifications.Email
|
||||
const string subject = "NzbDrone [TV] - Downloaded";
|
||||
var body = String.Format("{0} Downloaded and sorted.", message.Message);
|
||||
|
||||
_smtpProvider.SendEmail(Settings, subject, body);
|
||||
_emailService.SendEmail(Settings, subject, body);
|
||||
}
|
||||
|
||||
public override void AfterRename(Series series)
|
||||
{
|
||||
}
|
||||
|
||||
public override ValidationResult Test()
|
||||
{
|
||||
var failures = new List<ValidationFailure>();
|
||||
|
||||
failures.AddIfNotNull(_emailService.Test(Settings));
|
||||
|
||||
return new ValidationResult(failures);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
|
||||
namespace NzbDrone.Core.Notifications.Email
|
||||
{
|
||||
public class TestEmailCommand : Command
|
||||
{
|
||||
public override bool SendUpdatesToClient
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public string Server { get; set; }
|
||||
public int Port { get; set; }
|
||||
public bool Ssl { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string From { get; set; }
|
||||
public string To { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user