Skip to content

Commit

Permalink
Merge pull request #476 from DigitalExcellence/bugfix/475-project-ima…
Browse files Browse the repository at this point in the history
…ges-limit

Limited amount of images per project to 10
  • Loading branch information
RubenFricke authored Jun 29, 2021
2 parents 5c4b191 + 7c1b1d7 commit 0b99e31
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions API/Controllers/ProjectController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,17 @@ await callToActionOptionService.GetCallToActionOptionFromValueAsync(
return BadRequest(problem);
}

if(projectResource.ImageIds.Count() > 10)
{
ProblemDetails problem = new ProblemDetails
{
Title = "Too many images.",
Detail = "A project can not have more than 10 images.",
Instance = "9E3E4F91-A6ED-415F-8726-6D33BA0F200F"
};
return BadRequest(problem);
}

foreach(int projectResourceImageId in projectResource.ImageIds)
{
Models.File image = await fileService.FindAsync(projectResourceImageId);
Expand Down Expand Up @@ -575,6 +586,17 @@ await callToActionOptionService.GetCallToActionOptionFromValueAsync(
project.ProjectIcon = null;
}

if(projectResource.ImageIds.Count() > 10)
{
ProblemDetails problem = new ProblemDetails
{
Title = "Too many images.",
Detail = "A project can not have more than 10 images.",
Instance = "5D179737-046E-482B-B6D8-DDDCEF518107"
};
return BadRequest(problem);
}

project.Images.Clear();
foreach(int projectResourceImageId in projectResource.ImageIds)
{
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Include categories in retrieving a user's project - [#468](https://github.com/DigitalExcellence/dex-backend/issues/468)
- Lowercase file extensions on upload - [#472](https://github.com/DigitalExcellence/dex-backend/issues/472)
- Fixed an issue where Swagger could not authorize with IdentityServer - [#429](https://github.com/DigitalExcellence/dex-backend/issues/429)
- Projects now has a maximum of 10 images - [#475](https://github.com/DigitalExcellence/dex-backend/issues/475)

### Security

Expand Down

0 comments on commit 0b99e31

Please sign in to comment.