From 71f1148f07cb1f5c9315925f15707d1a33c16cd5 Mon Sep 17 00:00:00 2001 From: Kilian von Pflugk Date: Sun, 28 Jul 2024 19:37:46 +0200 Subject: [PATCH] check if episodes exists and update function docs --- .../Controllers/SkipIntroController.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs index 3d6ef46..e81333f 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs @@ -54,11 +54,19 @@ public class SkipIntroController : ControllerBase /// Episode ID to update timestamps for. /// New timestamps Introduction/Credits start and end times. /// New timestamps saved. + /// Given ID is not an Episode. /// No content. [Authorize(Policy = Policies.RequiresElevation)] [HttpPost("Episode/{Id}/Timestamps")] public ActionResult UpdateTimestamps([FromRoute] Guid id, [FromBody] TimeStamps timestamps) { + // only update existing episodes + var rawItem = Plugin.Instance!.GetItem(id); + if (rawItem == null || rawItem is not Episode episode) + { + return NotFound(); + } + if (timestamps?.Introduction.IntroEnd > 0.0) { var tr = new TimeRange(timestamps.Introduction.IntroStart, timestamps.Introduction.IntroEnd); @@ -80,7 +88,8 @@ public class SkipIntroController : ControllerBase /// Gets the timestamps for the provided episode. /// /// Episode ID. - /// Sucess. + /// Sucess. + /// Given ID is not an Episode. /// Episode Timestamps. [HttpGet("Episode/{Id}/Timestamps")] [ActionName("UpdateTimestamps")]