Skip to content

Commit

Permalink
fix: enable nullable on image controller & fix NRE
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed Dec 26, 2024
1 parent e3089b0 commit 340435b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Shoko.Server/API/v3/Controllers/ImageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Shoko.Server.Settings;
using Shoko.Server.Utilities;

#nullable enable
namespace Shoko.Server.API.v3.Controllers;

[ApiController]
Expand Down Expand Up @@ -159,7 +160,7 @@ public ActionResult GetRandomImageForType([FromRoute] Image.ImageType imageType)
public ActionResult<Image> GetRandomImageMetadataForType(
[FromRoute] Image.ImageType imageType,
[FromQuery] IncludeOnlyFilter includeRestricted = IncludeOnlyFilter.False,
[FromQuery, ModelBinder(typeof(CommaDelimitedModelBinder))] HashSet<SeriesType> seriesType = null,
[FromQuery, ModelBinder(typeof(CommaDelimitedModelBinder))] HashSet<SeriesType>? seriesType = null,
[FromQuery, Range(0, 100)] int maxAttempts = 5
)
{
Expand All @@ -184,7 +185,7 @@ public ActionResult<Image> GetRandomImageMetadataForType(

var image = new Image(metadata);
var series = ImageUtils.GetFirstSeriesForImage(metadata);
if (series.AniDB_Anime is not { } anime)
if (series?.AniDB_Anime is not { } anime)
continue;

if (includeRestricted != IncludeOnlyFilter.True)
Expand Down

0 comments on commit 340435b

Please sign in to comment.