1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Improved Trakt list validation

Fixes #5262

Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
This commit is contained in:
Qstick 2020-10-29 20:50:35 -04:00
parent a03d136aa4
commit 45011198e2
3 changed files with 20 additions and 4 deletions

View File

@ -13,6 +13,7 @@
using NzbDrone.Core.Indexers.Exceptions;
using NzbDrone.Core.Parser;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.ImportLists
{
@ -187,7 +188,9 @@ protected virtual ValidationFailure TestConnection()
if (releases.Empty())
{
return new ValidationFailure(string.Empty, "No results were returned from your 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)

View File

@ -8,6 +8,8 @@ public class TraktListSettingsValidator : TraktSettingsBaseValidator<TraktListSe
public TraktListSettingsValidator()
: base()
{
RuleFor(c => c.Username).NotEmpty();
RuleFor(c => c.Listname).NotEmpty();
}
}

View File

@ -14,9 +14,20 @@ public class TraktSettingsBaseValidator<TSettings> : AbstractValidator<TSettings
public TraktSettingsBaseValidator()
{
RuleFor(c => c.Link).ValidRootUrl();
RuleFor(c => c.AccessToken).NotEmpty();
RuleFor(c => c.RefreshToken).NotEmpty();
RuleFor(c => c.Expires).NotEmpty();
RuleFor(c => c.AccessToken).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
RuleFor(c => c.Rating)