From dc3ab7f1232aadaeb8e42a93dd98edbb16155c1a 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 60626b9..84f9d50 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Controllers/SkipIntroController.cs @@ -55,11 +55,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); @@ -82,7 +90,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")]