Fixed: Interactive search grabs rejected due to validation

pull/3072/head
Mark McDowall 6 years ago
parent cdde8cfdbe
commit bf86b09f4e

@ -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)

Loading…
Cancel
Save