fix(clips): remove redundant auth checks

This commit is contained in:
2026-07-01 23:19:51 +01:00
parent 76869c8c90
commit 3c8df9b328
3 changed files with 4 additions and 28 deletions

View File

@@ -66,9 +66,7 @@ public class ClipController {
@DeleteMapping("/{id}")
public ResponseEntity<APIResponse<String>> deleteClip(@PathVariable Long id) {
if (!clipService.deleteClip(id)) {
return ResponseEntity.notFound().build();
}
clipService.deleteClip(id);
return ResponseEntity.ok(
new APIResponse<>(

View File

@@ -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);

View File

@@ -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;
}
/**