mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-27 17:01:16 -04:00
Add try catch (#14154)
This commit is contained in:
parent
a702b62553
commit
9ab22e9f8b
1 changed files with 30 additions and 11 deletions
|
@ -450,22 +450,41 @@ public class PlaylistsController : BaseJellyfinApiController
|
||||||
{
|
{
|
||||||
var callingUserId = User.GetUserId();
|
var callingUserId = User.GetUserId();
|
||||||
|
|
||||||
var playlist = _playlistManager.GetPlaylistForUser(Guid.Parse(playlistId), callingUserId);
|
if (!callingUserId.IsEmpty())
|
||||||
if (playlist is null)
|
|
||||||
{
|
{
|
||||||
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();
|
||||||
|
|
||||||
|
if (!isApiKey)
|
||||||
|
{
|
||||||
|
return Forbid();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var isPermitted = playlist.OwnerUserId.Equals(callingUserId)
|
try
|
||||||
|| playlist.Shares.Any(s => s.CanEdit && s.UserId.Equals(callingUserId));
|
|
||||||
|
|
||||||
if (!isPermitted)
|
|
||||||
{
|
{
|
||||||
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>
|
/// <summary>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue