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