diff options
| author | sharinganthief <phillipjberglund@gmail.com> | 2025-06-06 08:54:53 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-06 06:54:53 -0600 |
| commit | 9ab22e9f8b7dd47ed6bd2dade2e8612c6a909ee2 (patch) | |
| tree | 09ef6ccc9120494974d2a488ff2b0f1f15d9adf9 /Jellyfin.Api/Controllers/PlaylistsController.cs | |
| parent | a702b62553487fe1c87f9f754a52b630730f88ad (diff) | |
Add try catch (#14154)
Diffstat (limited to 'Jellyfin.Api/Controllers/PlaylistsController.cs')
| -rw-r--r-- | Jellyfin.Api/Controllers/PlaylistsController.cs | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/Jellyfin.Api/Controllers/PlaylistsController.cs b/Jellyfin.Api/Controllers/PlaylistsController.cs index ec5fdab38..79c71d23a 100644 --- a/Jellyfin.Api/Controllers/PlaylistsController.cs +++ b/Jellyfin.Api/Controllers/PlaylistsController.cs @@ -450,22 +450,41 @@ public class PlaylistsController : BaseJellyfinApiController { var callingUserId = User.GetUserId(); - var playlist = _playlistManager.GetPlaylistForUser(Guid.Parse(playlistId), callingUserId); - if (playlist is null) + if (!callingUserId.IsEmpty()) { - return NotFound("Playlist not found"); + var playlist = _playlistManager.GetPlaylistForUser(Guid.Parse(playlistId), callingUserId); + if (playlist is null) + { + return NotFound("Playlist not found"); + } + + var isPermitted = playlist.OwnerUserId.Equals(callingUserId) + || playlist.Shares.Any(s => s.CanEdit && s.UserId.Equals(callingUserId)); + + if (!isPermitted) + { + return Forbid(); + } } + else + { + var isApiKey = User.GetIsApiKey(); - var isPermitted = playlist.OwnerUserId.Equals(callingUserId) - || playlist.Shares.Any(s => s.CanEdit && s.UserId.Equals(callingUserId)); + if (!isApiKey) + { + return Forbid(); + } + } - if (!isPermitted) + try { - return Forbid(); + await _playlistManager.RemoveItemFromPlaylistAsync(playlistId, entryIds).ConfigureAwait(false); + return NoContent(); + } + catch (ArgumentException) + { + return NotFound(); } - - await _playlistManager.RemoveItemFromPlaylistAsync(playlistId, entryIds).ConfigureAwait(false); - return NoContent(); } /// <summary> |
