fix(202): make RemoteLibrariesEditScreen reviewable (NUL delimiter -> \u0000 escape) + Plex library-prefs missing-id 422 guard (review)
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 7s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 5m28s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 6m26s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 7s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 5m28s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 6m26s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
This commit is contained in:
@@ -259,6 +259,27 @@ public class PlexMediaSourcesControllerTests
|
||||
await _mediator.DidNotReceive().Send(Arg.Any<UpdatePlexLibraryPreferences>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ReplaceLibraries_Should_Return_422_When_An_Owned_Library_Is_Missing()
|
||||
{
|
||||
SourceExists(true);
|
||||
_mediator.Send(Arg.Any<GetPlexLibrariesBySourceId>(), Arg.Any<CancellationToken>())
|
||||
.Returns(new List<PlexLibraryViewModel>
|
||||
{
|
||||
new(5, "Movies", LibraryMediaKind.Movies, true),
|
||||
new(6, "Shows", LibraryMediaKind.Shows, true)
|
||||
});
|
||||
|
||||
// request omits owned id 6 -> 422: the PUT is a complete flag document (§C4a), matching Jellyfin/Emby
|
||||
IActionResult result = await _controller.ReplaceLibraryPreferences(
|
||||
3,
|
||||
new ReplaceRemoteLibraryPreferencesRequest([new RemoteLibraryPreferenceRequest(5, true)]),
|
||||
CancellationToken.None);
|
||||
|
||||
result.ShouldBeOfType<UnprocessableEntityObjectResult>();
|
||||
await _mediator.DidNotReceive().Send(Arg.Any<UpdatePlexLibraryPreferences>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ReplaceLibraries_Should_Save_Enqueue_Ordered_Pair_And_Return_Reloaded()
|
||||
{
|
||||
|
||||
@@ -164,6 +164,18 @@ public class PlexMediaSourcesController(
|
||||
.ToErrorResult();
|
||||
}
|
||||
|
||||
// Require the complete set of this source's libraries (§C4a; matches Jellyfin/Emby): the PUT is a
|
||||
// full flag document, so an omitted owned id would silently keep its old sync state.
|
||||
var incomingIds = libraries.Map(l => l.Id).ToList();
|
||||
var missingIds = ownedIds.Where(ownedId => !incomingIds.Contains(ownedId)).ToList();
|
||||
if (missingIds.Count > 0)
|
||||
{
|
||||
return BaseError.New(
|
||||
$"The request must include every library for Plex media source {id} " +
|
||||
$"(missing id(s) {string.Join(", ", missingIds)})")
|
||||
.ToErrorResult();
|
||||
}
|
||||
|
||||
Either<BaseError, Unit> result =
|
||||
await mediator.Send(request.ToPlexCommand(), cancellationToken);
|
||||
if (result.IsLeft)
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user