From 3c8df9b3284af7a36b119205334b7452f661352b Mon Sep 17 00:00:00 2001 From: Dylan De Faoite Date: Wed, 1 Jul 2026 23:19:51 +0100 Subject: [PATCH] fix(clips): remove redundant auth checks --- .../vodsystem/controllers/ClipController.java | 4 +--- .../ddf/vodsystem/services/ClipService.java | 23 ++----------------- .../ddf/vodsystem/services/VodService.java | 5 +--- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/ddf/vodsystem/controllers/ClipController.java b/src/main/java/com/ddf/vodsystem/controllers/ClipController.java index 4112357..f4a25bb 100644 --- a/src/main/java/com/ddf/vodsystem/controllers/ClipController.java +++ b/src/main/java/com/ddf/vodsystem/controllers/ClipController.java @@ -66,9 +66,7 @@ public class ClipController { @DeleteMapping("/{id}") public ResponseEntity> deleteClip(@PathVariable Long id) { - if (!clipService.deleteClip(id)) { - return ResponseEntity.notFound().build(); - } + clipService.deleteClip(id); return ResponseEntity.ok( new APIResponse<>( diff --git a/src/main/java/com/ddf/vodsystem/services/ClipService.java b/src/main/java/com/ddf/vodsystem/services/ClipService.java index af4374b..6000245 100644 --- a/src/main/java/com/ddf/vodsystem/services/ClipService.java +++ b/src/main/java/com/ddf/vodsystem/services/ClipService.java @@ -97,10 +97,6 @@ public class ClipService { public Clip updateClip(Long id, ClipUpdateRequest newFields) { Clip clip = getClipById(id); - if (!isAuthenticatedForClip(clip)) { - throw new NotAuthenticated("You are not authorized to access clip: " + id); - } - if (newFields.title() != null) { clip.setTitle(newFields.title()); } @@ -116,22 +112,15 @@ public class ClipService { * Deletes a clip and its associated files from disk. * * @param id the ID of the clip to delete - * @return {@code true} on success; always throws rather than returning {@code false} * @throws ClipNotFound if no clip with {@code id} exists * @throws NotAuthenticated if the current user does not own the clip */ - public boolean deleteClip(Long id) { + public void deleteClip(Long id) { Clip clip = getClipById(id); - - if (!isAuthenticatedForClip(clip)) { - throw new NotAuthenticated("You are not authorized to delete this clip"); - } - deleteClipFiles(clip); clipRepository.delete(clip); logger.info("Clip with ID {} deleted successfully", id); - return true; } /** @@ -160,15 +149,11 @@ public class ClipService { public Resource downloadClip(Long id) { Clip clip = getClipById(id); - if (!isAuthenticatedForClip(clip)) { - throw new NotAuthenticated("Not authenticated for this clip"); - } - String path = clip.getVideoPath(); Path file = directoryService.resolvePath(path); if (!Files.exists(file)) { - throw new JobNotFound("Clip file not found"); + throw new ClipNotFound("Clip file not found"); } return new FileSystemResource(file); @@ -185,10 +170,6 @@ public class ClipService { public Resource downloadThumbnail(Long id) { Clip clip = getClipById(id); - if (!isAuthenticatedForClip(clip)) { - throw new NotAuthenticated("Not authenticated for this clip thumbnail"); - } - String path = clip.getThumbnailPath(); Path file = directoryService.resolvePath(path); diff --git a/src/main/java/com/ddf/vodsystem/services/VodService.java b/src/main/java/com/ddf/vodsystem/services/VodService.java index fe40096..ff51c87 100644 --- a/src/main/java/com/ddf/vodsystem/services/VodService.java +++ b/src/main/java/com/ddf/vodsystem/services/VodService.java @@ -112,18 +112,15 @@ public class VodService { * Deletes a VoD and its associated files from disk. * * @param id the ID of the VoD to delete - * @return {@code true} on success; always throws rather than returning {@code false} * @throws VodNotFound if no VoD with {@code id} exists * @throws NotAuthenticated if the current user does not own the VoD */ - public boolean deleteVod(Long id) { + public void deleteVod(Long id) { Vod vod = getVodById(id); - deleteVodFiles(vod); vodRepository.delete(vod); logger.info("Vod with ID {} deleted successfully", id); - return true; } /**