Improved Trakt list validation
New: Able to add empty Trakt lists (shows warning during test) Fixed: Show error in UI if Trakt list hasn't been authenticated Closes #4022
This commit is contained in:
parent
fa2e70d571
commit
3fc3aef268
|
@ -12,6 +12,7 @@ using NzbDrone.Core.ImportLists.Exceptions;
|
||||||
using NzbDrone.Core.Indexers.Exceptions;
|
using NzbDrone.Core.Indexers.Exceptions;
|
||||||
using NzbDrone.Core.Parser;
|
using NzbDrone.Core.Parser;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
using NzbDrone.Core.Validation;
|
||||||
|
|
||||||
namespace NzbDrone.Core.ImportLists
|
namespace NzbDrone.Core.ImportLists
|
||||||
{
|
{
|
||||||
|
@ -212,7 +213,9 @@ namespace NzbDrone.Core.ImportLists
|
||||||
|
|
||||||
if (releases.Empty())
|
if (releases.Empty())
|
||||||
{
|
{
|
||||||
return new ValidationFailure(string.Empty, "No results were returned from your import list, please check your settings.");
|
return new NzbDroneValidationFailure(string.Empty,
|
||||||
|
"No results were returned from your import list, please check your settings.")
|
||||||
|
{IsWarning = true};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (RequestLimitReachedException)
|
catch (RequestLimitReachedException)
|
||||||
|
|
|
@ -8,6 +8,8 @@ namespace NzbDrone.Core.ImportLists.Trakt.List
|
||||||
public TraktListSettingsValidator()
|
public TraktListSettingsValidator()
|
||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
|
RuleFor(c => c.Username).NotEmpty();
|
||||||
|
RuleFor(c => c.Listname).NotEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ using System.Text.RegularExpressions;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Core.Annotations;
|
using NzbDrone.Core.Annotations;
|
||||||
using NzbDrone.Core.ThingiProvider;
|
|
||||||
using NzbDrone.Core.Validation;
|
using NzbDrone.Core.Validation;
|
||||||
|
|
||||||
namespace NzbDrone.Core.ImportLists.Trakt
|
namespace NzbDrone.Core.ImportLists.Trakt
|
||||||
|
@ -14,9 +13,20 @@ namespace NzbDrone.Core.ImportLists.Trakt
|
||||||
public TraktSettingsBaseValidator()
|
public TraktSettingsBaseValidator()
|
||||||
{
|
{
|
||||||
RuleFor(c => c.BaseUrl).ValidRootUrl();
|
RuleFor(c => c.BaseUrl).ValidRootUrl();
|
||||||
RuleFor(c => c.AccessToken).NotEmpty();
|
|
||||||
RuleFor(c => c.RefreshToken).NotEmpty();
|
RuleFor(c => c.AccessToken).NotEmpty()
|
||||||
RuleFor(c => c.Expires).NotEmpty();
|
.OverridePropertyName("SignIn")
|
||||||
|
.WithMessage("Must authenticate with Trakt");
|
||||||
|
|
||||||
|
RuleFor(c => c.RefreshToken).NotEmpty()
|
||||||
|
.OverridePropertyName("SignIn")
|
||||||
|
.WithMessage("Must authenticate with Trakt")
|
||||||
|
.When(c => c.AccessToken.IsNotNullOrWhiteSpace());
|
||||||
|
|
||||||
|
RuleFor(c => c.Expires).NotEmpty()
|
||||||
|
.OverridePropertyName("SignIn")
|
||||||
|
.WithMessage("Must authenticate with Trakt")
|
||||||
|
.When(c => c.AccessToken.IsNotNullOrWhiteSpace() && c.RefreshToken.IsNotNullOrWhiteSpace());
|
||||||
|
|
||||||
// Loose validation @TODO
|
// Loose validation @TODO
|
||||||
RuleFor(c => c.Rating)
|
RuleFor(c => c.Rating)
|
||||||
|
|
Loading…
Reference in New Issue