Fixed: Better NetImport Validation (Don't Allow Bad ProfileIds)

pull/4588/head
Qstick 4 years ago
parent aa6c8f493e
commit 9bf50d4493

@ -1,17 +1,19 @@
using FluentValidation;
using NzbDrone.Core.NetImport;
using NzbDrone.Core.Validation;
using NzbDrone.Core.Validation.Paths;
namespace NzbDrone.Api.NetImport
{
public class NetImportModule : ProviderModuleBase<NetImportResource, INetImport, NetImportDefinition>
{
public NetImportModule(NetImportFactory netImportFactory)
public NetImportModule(NetImportFactory netImportFactory, ProfileExistsValidator profileExistsValidator)
: base(netImportFactory, "netimport")
{
PostValidator.RuleFor(c => c.RootFolderPath).IsValidPath();
PostValidator.RuleFor(c => c.MinimumAvailability).NotNull();
PostValidator.RuleFor(c => c.ProfileId).NotNull();
SharedValidator.RuleFor(c => c.ProfileId).ValidId();
SharedValidator.RuleFor(c => c.ProfileId).SetValidator(profileExistsValidator);
}
protected override void MapToResource(NetImportResource resource, NetImportDefinition definition)

@ -1,5 +1,6 @@
using FluentValidation;
using NzbDrone.Core.NetImport;
using NzbDrone.Core.Validation;
using NzbDrone.Core.Validation.Paths;
namespace Radarr.Api.V3.NetImport
@ -8,12 +9,13 @@ namespace Radarr.Api.V3.NetImport
{
public static readonly NetImportResourceMapper ResourceMapper = new NetImportResourceMapper();
public NetImportModule(NetImportFactory netImportFactory)
public NetImportModule(NetImportFactory netImportFactory, ProfileExistsValidator profileExistsValidator)
: base(netImportFactory, "netimport", ResourceMapper)
{
SharedValidator.RuleFor(c => c.RootFolderPath).IsValidPath();
SharedValidator.RuleFor(c => c.MinimumAvailability).NotNull();
SharedValidator.RuleFor(c => c.QualityProfileId).NotNull();
SharedValidator.RuleFor(c => c.QualityProfileId).ValidId();
SharedValidator.RuleFor(c => c.QualityProfileId).SetValidator(profileExistsValidator);
}
protected override void Validate(NetImportDefinition definition, bool includeWarnings)

Loading…
Cancel
Save