Skip to content

Commit

Permalink
Fixed: Enforce validation warnings
Browse files Browse the repository at this point in the history
(cherry picked from commit 48ee1158ad4213fd0690842e2672f52d08f7ad26)
  • Loading branch information
mynameisbogdan committed May 28, 2023
1 parent fcfec1b commit 5864a09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Expand Up @@ -32,9 +32,9 @@ function createSaveProviderHandler(section, url, options = {}) {
const params = { ...queryParams };

// If the user is re-saving the same provider without changes
// force it to be saved. Only applies to editing existing providers.
// force it to be saved.

if (id && _.isEqual(saveData, lastSaveData)) {
if (_.isEqual(saveData, lastSaveData)) {
params.forceSave = true;
}

Expand Down
8 changes: 4 additions & 4 deletions src/Prowlarr.Api.V1/ProviderControllerBase.cs
Expand Up @@ -59,9 +59,9 @@ public List<TProviderResource> GetAll()

[RestPostById]
[Produces("application/json")]
public ActionResult<TProviderResource> CreateProvider(TProviderResource providerResource)
public ActionResult<TProviderResource> CreateProvider([FromBody] TProviderResource providerResource, [FromQuery] bool forceSave = false)
{
var providerDefinition = GetDefinition(providerResource, true, false, false);
var providerDefinition = GetDefinition(providerResource, true, !forceSave, false);

if (providerDefinition.Enable)
{
Expand All @@ -77,7 +77,7 @@ public ActionResult<TProviderResource> CreateProvider(TProviderResource provider
[Produces("application/json")]
public ActionResult<TProviderResource> UpdateProvider([FromBody] TProviderResource providerResource, [FromQuery] bool forceSave = false)
{
var providerDefinition = GetDefinition(providerResource, true, false, false);
var providerDefinition = GetDefinition(providerResource, true, !forceSave, false);

// Only test existing definitions if it is enabled and forceSave isn't set.
if (providerDefinition.Enable && !forceSave)
Expand Down Expand Up @@ -195,7 +195,7 @@ protected virtual void Test(TProviderDefinition definition, bool includeWarnings

protected void VerifyValidationResult(ValidationResult validationResult, bool includeWarnings)
{
var result = new NzbDroneValidationResult(validationResult.Errors);
var result = validationResult as NzbDroneValidationResult ?? new NzbDroneValidationResult(validationResult.Errors);

if (includeWarnings && (!result.IsValid || result.HasWarnings))
{
Expand Down

0 comments on commit 5864a09

Please sign in to comment.