Fixed: Interactive search grabs rejected due to validation

This commit is contained in:
Mark McDowall 2019-04-09 09:17:14 -07:00
parent cdde8cfdbe
commit bf86b09f4e
1 changed files with 3 additions and 14 deletions

View File

@ -17,7 +17,6 @@ using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Validation;
using Sonarr.Http.Extensions;
using Sonarr.Http.REST;
using HttpStatusCode = System.Net.HttpStatusCode;
namespace Sonarr.Api.V3.Indexers
@ -33,7 +32,6 @@ namespace Sonarr.Api.V3.Indexers
private readonly IEpisodeService _episodeService;
private readonly IParsingService _parsingService;
private readonly Logger _logger;
private ResourceValidator<ReleaseResource> _releaseValidator;
private readonly ICached<RemoteEpisode> _remoteEpisodeCache;
@ -58,26 +56,17 @@ namespace Sonarr.Api.V3.Indexers
_parsingService = parsingService;
_logger = logger;
_releaseValidator = new ResourceValidator<ReleaseResource>();
_releaseValidator.RuleFor(s => s.DownloadAllowed).Equal(true);
_releaseValidator.RuleFor(s => s.IndexerId).ValidId();
_releaseValidator.RuleFor(s => s.Guid).NotEmpty();
PostValidator.RuleFor(s => s.IndexerId).ValidId();
PostValidator.RuleFor(s => s.Guid).NotEmpty();
GetResourceAll = GetReleases;
Post["/"] = x => DownloadRelease(this.Bind<ReleaseResource>());
Post["/"] = x => DownloadRelease(ReadResourceFromRequest());
_remoteEpisodeCache = cacheManager.GetCache<RemoteEpisode>(GetType(), "remoteEpisodes");
}
private Response DownloadRelease(ReleaseResource release)
{
var validationFailures = _releaseValidator.Validate(release).Errors;
if (validationFailures.Any())
{
throw new ValidationException(validationFailures);
}
var remoteEpisode = _remoteEpisodeCache.Find(GetCacheKey(release));
if (remoteEpisode == null)