Skip to content

Commit

Permalink
Update EmulateOldDeliveryChannelProperties summary, reject IOP/TP in …
Browse files Browse the repository at this point in the history
…HydraImageValidator if legacy disabled
  • Loading branch information
griffri committed May 29, 2024
1 parent 39dd790 commit bb63a29
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
6 changes: 0 additions & 6 deletions src/protagonist/API/Features/Image/ImageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,6 @@ public async Task<IActionResult> GetImage(int customerId, int spaceId, string im
hydraAsset = LegacyModeConverter.VerifyAndConvertToModernFormat(hydraAsset);
}

if(hydraAsset.ImageOptimisationPolicy != null || hydraAsset.ThumbnailPolicy != null)
{
return this.HydraProblem("ImageOptimisationPolicy and ThumbnailPolicy are disabled", null,
400, "Bad Request");
}

if (hydraAsset.ModelId == null)
{
hydraAsset.ModelId = imageId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ public HydraImageValidator(IOptions<ApiSettings> apiSettings)

When(a => !a.DeliveryChannels.IsNullOrEmpty(), ImageDeliveryChannelDependantValidation);

// Legacy policy fields
RuleFor(a => a.ImageOptimisationPolicy)
.Null()
.When(_ => !apiSettings.Value.EmulateOldDeliveryChannelProperties)
.WithMessage("'ImageOptimisationPolicy' is disabled");

RuleFor(a => a.ThumbnailPolicy)
.Null()
.When(_ => !apiSettings.Value.EmulateOldDeliveryChannelProperties)
.WithMessage("'ThumbnailPolicy' is disabled");

// System edited fields
RuleFor(a => a.Width).Empty().WithMessage("Should not include width");
RuleFor(a => a.Height).Empty().WithMessage("Should not include height");
Expand Down
6 changes: 3 additions & 3 deletions src/protagonist/API/Settings/ApiSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public string RestrictedAssetIdCharacterString
}

/// <summary>
/// Whether incoming old delivery channel properties (e.g wcDeliveryChannels, imageOptimisationPolicy,
/// thumbnailPolicy) are supported and translated into the new format
/// Whether old delivery channel properties (e.g imageOptimisationPolicy, thumbnailPolicy)
/// on legacy payloads are supported and translated into the new format
/// </summary>
public bool EmulateOldDeliveryChannelProperties { get; set; } = false;
public bool EmulateOldDeliveryChannelProperties { get; set; }
}

0 comments on commit bb63a29

Please sign in to comment.