Apply review suggestions

This commit is contained in:
Shadowghost 2024-04-03 21:20:30 +02:00
parent 51e2faa448
commit e3897fe5dd
3 changed files with 16 additions and 9 deletions

View file

@ -94,7 +94,7 @@ public class PlaylistsController : BaseJellyfinApiController
UserId = userId.Value, UserId = userId.Value,
MediaType = mediaType ?? createPlaylistRequest?.MediaType, MediaType = mediaType ?? createPlaylistRequest?.MediaType,
Users = createPlaylistRequest?.Users.ToArray() ?? [], Users = createPlaylistRequest?.Users.ToArray() ?? [],
Public = createPlaylistRequest?.Public Public = createPlaylistRequest?.IsPublic
}).ConfigureAwait(false); }).ConfigureAwait(false);
return result; return result;
@ -143,7 +143,7 @@ public class PlaylistsController : BaseJellyfinApiController
Name = updatePlaylistRequest.Name, Name = updatePlaylistRequest.Name,
Ids = updatePlaylistRequest.Ids, Ids = updatePlaylistRequest.Ids,
Users = updatePlaylistRequest.Users, Users = updatePlaylistRequest.Users,
Public = updatePlaylistRequest.Public Public = updatePlaylistRequest.IsPublic
}).ConfigureAwait(false); }).ConfigureAwait(false);
return NoContent(); return NoContent();
@ -180,17 +180,19 @@ public class PlaylistsController : BaseJellyfinApiController
} }
/// <summary> /// <summary>
/// Get a playlist users. /// Get a playlist user.
/// </summary> /// </summary>
/// <param name="playlistId">The playlist id.</param> /// <param name="playlistId">The playlist id.</param>
/// <param name="userId">The user id.</param> /// <param name="userId">The user id.</param>
/// <response code="200">User permission found.</response> /// <response code="200">User permission found.</response>
/// <response code="200">Access forbidden.</response>
/// <response code="404">Playlist not found.</response> /// <response code="404">Playlist not found.</response>
/// <returns> /// <returns>
/// <see cref="PlaylistUserPermissions"/>. /// <see cref="PlaylistUserPermissions"/>.
/// </returns> /// </returns>
[HttpGet("{playlistId}/Users/{userId}")] [HttpGet("{playlistId}/Users/{userId}")]
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status404NotFound)]
public ActionResult<PlaylistUserPermissions?> GetPlaylistUser( public ActionResult<PlaylistUserPermissions?> GetPlaylistUser(
[FromRoute, Required] Guid playlistId, [FromRoute, Required] Guid playlistId,
@ -209,7 +211,12 @@ public class PlaylistsController : BaseJellyfinApiController
|| playlist.Shares.Any(s => s.CanEdit && s.UserId.Equals(callingUserId)) || playlist.Shares.Any(s => s.CanEdit && s.UserId.Equals(callingUserId))
|| userId.Equals(callingUserId); || userId.Equals(callingUserId);
if (isPermitted && userPermission is not null) if (!isPermitted)
{
return Forbid();
}
if (userPermission is not null)
{ {
return userPermission; return userPermission;
} }
@ -218,7 +225,7 @@ public class PlaylistsController : BaseJellyfinApiController
} }
/// <summary> /// <summary>
/// Modify a user to a playlist's users. /// Modify a user of a playlist's users.
/// </summary> /// </summary>
/// <param name="playlistId">The playlist id.</param> /// <param name="playlistId">The playlist id.</param>
/// <param name="userId">The user id.</param> /// <param name="userId">The user id.</param>
@ -237,7 +244,7 @@ public class PlaylistsController : BaseJellyfinApiController
public async Task<ActionResult> UpdatePlaylistUser( public async Task<ActionResult> UpdatePlaylistUser(
[FromRoute, Required] Guid playlistId, [FromRoute, Required] Guid playlistId,
[FromRoute, Required] Guid userId, [FromRoute, Required] Guid userId,
[FromBody(EmptyBodyBehavior = EmptyBodyBehavior.Allow)] UpdatePlaylistUserDto updatePlaylistUserRequest) [FromBody(EmptyBodyBehavior = EmptyBodyBehavior.Allow), Required] UpdatePlaylistUserDto updatePlaylistUserRequest)
{ {
var callingUserId = User.GetUserId(); var callingUserId = User.GetUserId();
@ -265,7 +272,7 @@ public class PlaylistsController : BaseJellyfinApiController
} }
/// <summary> /// <summary>
/// Remove a user from a playlist's shares. /// Remove a user from a playlist's users.
/// </summary> /// </summary>
/// <param name="playlistId">The playlist id.</param> /// <param name="playlistId">The playlist id.</param>
/// <param name="userId">The user id.</param> /// <param name="userId">The user id.</param>

View file

@ -41,5 +41,5 @@ public class CreatePlaylistDto
/// <summary> /// <summary>
/// Gets or sets a value indicating whether the playlist is public. /// Gets or sets a value indicating whether the playlist is public.
/// </summary> /// </summary>
public bool Public { get; set; } = true; public bool IsPublic { get; set; } = true;
} }

View file

@ -30,5 +30,5 @@ public class UpdatePlaylistDto
/// <summary> /// <summary>
/// Gets or sets a value indicating whether the playlist is public. /// Gets or sets a value indicating whether the playlist is public.
/// </summary> /// </summary>
public bool? Public { get; set; } public bool? IsPublic { get; set; }
} }