mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 17:11:10 +00:00
Moves media library scanning to domain layer
This commit is contained in:
1 parent
8b51abe0b2
commit
c4246d2e69
209 files changed
+3793
-641
No files matched your search
+1
-1
@@ -48,7 +48,7 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
RequestParam(r => r.SaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional.");
|
||||
|
||||
ResponseParam<LibraryResponse>(r => r.Id, "The unique identifier of the entity.");
|
||||
ResponseParam<LibraryResponse>(r => r.UserId, "The Id of the user owning the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.UserId, "The unique identifier of the user owning the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.Title, "The title of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.LibraryType, "The type of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located.");
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ using System.Threading.Tasks;
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.CancelLibrariesScan;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/cancel-scan</c> route.
|
||||
/// API endpoint for the <c>/libraries/scans/cancel</c> route.
|
||||
/// </summary>
|
||||
public class CancelLibrariesScanEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
|
||||
+4
-4
@@ -21,7 +21,7 @@ public class CancelLibrariesScanEndpointSummary : Summary<CancelLibrariesScanEnd
|
||||
Summary = "Cancells the previously started scan of all media libraries.";
|
||||
Description = "Cancells the scanning process of all media libraries of a user, or all libraries, if the user making the request is an Admin.";
|
||||
|
||||
Response(204, "The media libraries scan was successfully cancelled.");
|
||||
Response(204, "The media libraries scan was successfully canceled.");
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
example: new[]
|
||||
@@ -32,7 +32,7 @@ public class CancelLibrariesScanEndpointSummary : Summary<CancelLibrariesScanEnd
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/libraries/cancel-scan"
|
||||
instance = "/api/v1/libraries/scans/cancel"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -40,7 +40,7 @@ public class CancelLibrariesScanEndpointSummary : Summary<CancelLibrariesScanEnd
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
|
||||
instance = "/api/v1/libraries/cancel-scan"
|
||||
instance = "/api/v1/libraries/scans/cancel"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -48,7 +48,7 @@ public class CancelLibrariesScanEndpointSummary : Summary<CancelLibrariesScanEnd
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/cancel-scan"
|
||||
instance = "/api/v1/libraries/scans/cancel"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
+4
-2
@@ -1,7 +1,9 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.CancelLibrariesScan;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.CancelLibraryScan;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.Management;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
@@ -14,7 +16,7 @@ using System.Threading.Tasks;
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.CancelLibraryScan;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/{id}/cancel-scan</c> route.
|
||||
/// API endpoint for the <c>/libraries/{libraryId}/scans/{scanId}/cancel</c> route.
|
||||
/// </summary>
|
||||
public class CancelLibraryScanEndpoint : BaseEndpoint<CancelLibraryScanRequest, IResult>
|
||||
{
|
||||
@@ -46,7 +48,7 @@ public class CancelLibraryScanEndpoint : BaseEndpoint<CancelLibraryScanRequest,
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(CancelLibraryScanRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<Success> result = await _sender.Send(new CancelLibrariesScanCommand(), cancellationToken).ConfigureAwait(false);
|
||||
ErrorOr<Success> result = await _sender.Send(request.ToCommand(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.NoContent(), Problem);
|
||||
}
|
||||
}
|
||||
+19
-8
@@ -1,5 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
@@ -10,15 +12,23 @@ namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.CancelLibrar
|
||||
/// Class used for providing a textual description for the <see cref="CancelLibraryScanEndpoint"/> API endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class CancelLibraryScanEndpointSummary : Summary<CancelLibraryScanEndpoint, EmptyRequest>
|
||||
public class CancelLibraryScanEndpointSummary : Summary<CancelLibraryScanEndpoint, CancelLibraryScanRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CancelLibraryScanEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public CancelLibraryScanEndpointSummary()
|
||||
{
|
||||
Summary = "Cancells the previously started scan of a media library.";
|
||||
Description = "Cancells the scanning process of a media library of a user, if the user making the request is an Admin or the library belongs to them.";
|
||||
Summary = "Cancels the previously started scan of a media library.";
|
||||
Description = "Cancels the scanning process of a media library of a user, if the user making the request is an Admin or the library belongs to them.";
|
||||
|
||||
ExampleRequest = new CancelLibraryScanRequest(
|
||||
LibraryId: Guid.NewGuid(),
|
||||
ScanId: Guid.NewGuid()
|
||||
);
|
||||
|
||||
RequestParam(r => r.LibraryId, "The unique identifier of the media library whose scan is cancelled. Required.");
|
||||
RequestParam(r => r.ScanId, "The Id of scan to cancel. Required.");
|
||||
|
||||
Response(204, "The media library scan was successfully cancelled.");
|
||||
|
||||
@@ -31,7 +41,7 @@ public class CancelLibraryScanEndpointSummary : Summary<CancelLibraryScanEndpoin
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/libraries/{id}/cancel-scan"
|
||||
instance = "/api/v1/libraries/{libraryId}/scans/{scanId}/cancel"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -39,7 +49,7 @@ public class CancelLibraryScanEndpointSummary : Summary<CancelLibraryScanEndpoin
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
|
||||
instance = "/api/v1/libraries/{id}/cancel-scan"
|
||||
instance = "/api/v1/libraries/{libraryId}/scans/{scanId}/cancel"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -47,7 +57,7 @@ public class CancelLibraryScanEndpointSummary : Summary<CancelLibraryScanEndpoin
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/{id}/cancel-scan"
|
||||
instance = "/api/v1/libraries/{libraryId}/scans/{scanId}/cancel"
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -59,13 +69,14 @@ public class CancelLibraryScanEndpointSummary : Summary<CancelLibraryScanEndpoin
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/{id}/cancel-scan",
|
||||
instance = "/api/v1/libraries/{libraryId}/scans/{scanId}/cancel",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
"General.Validation", new[]
|
||||
{
|
||||
"LibraryIdCannotBeEmpty"
|
||||
"LibraryIdCannotBeEmpty",
|
||||
"ScanIdCannotBeEmpty"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ public class DeleteLibraryEndpointSummary : Summary<DeleteLibraryEndpoint, Delet
|
||||
Id: Guid.NewGuid()
|
||||
);
|
||||
|
||||
RequestParam(r => r.Id, "The Id of the media library to be deleted. Required.");
|
||||
RequestParam(r => r.Id, "The unique identifier of the media library to be deleted. Required.");
|
||||
|
||||
Response(200, "The media library was successfuly deleted.");
|
||||
|
||||
|
||||
+2
-2
@@ -28,10 +28,10 @@ public class GetLibraryEndpointSummary : Summary<GetLibraryEndpoint, GetLibraryR
|
||||
Id: Guid.NewGuid()
|
||||
);
|
||||
|
||||
RequestParam(r => r.Id, "The Id of the media library. Required.");
|
||||
RequestParam(r => r.Id, "The unique identifier of the media library. Required.");
|
||||
|
||||
ResponseParam<LibraryResponse>(r => r.Id, "The unique identifier of the entity.");
|
||||
ResponseParam<LibraryResponse>(r => r.UserId, "The Id of the user owning the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.UserId, "The unique identifier of the user owning the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.Title, "The title of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.LibraryType, "The type of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located.");
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ using System.Threading.Tasks;
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.ScanLibraries;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/scan</c> route.
|
||||
/// API endpoint for the <c>/libraries/scans</c> route.
|
||||
/// </summary>
|
||||
public class ScanLibrariesEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
|
||||
+3
-3
@@ -42,7 +42,7 @@ public class ScanLibrariesEndpointSummary : Summary<ScanLibrariesEndpoint, Empty
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/libraries/scan"
|
||||
instance = "/api/v1/libraries/scans"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -50,7 +50,7 @@ public class ScanLibrariesEndpointSummary : Summary<ScanLibrariesEndpoint, Empty
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
|
||||
instance = "/api/v1/libraries/scan"
|
||||
instance = "/api/v1/libraries/scans"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -58,7 +58,7 @@ public class ScanLibrariesEndpointSummary : Summary<ScanLibrariesEndpoint, Empty
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/scan"
|
||||
instance = "/api/v1/libraries/scans"
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
+2
-2
@@ -15,14 +15,14 @@ using System.Threading.Tasks;
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.ScanLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/{id}/scan</c> route.
|
||||
/// API endpoint for the <c>/libraries/{id}/scans</c> route.
|
||||
/// </summary>
|
||||
public class ScanLibraryEndpoint : BaseEndpoint<ScanLibraryRequest, IResult>
|
||||
{
|
||||
private readonly ISender _sender;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScanLibrariesEndpoint"/> class.
|
||||
/// Initializes a new instance of the <see cref="ScanLibraryEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="sender">Injected service for mediating commands and queries.</param>
|
||||
public ScanLibraryEndpoint(ISender sender)
|
||||
|
||||
+8
-8
@@ -37,7 +37,7 @@ public class ScanLibraryEndpointSummary : Summary<ScanLibraryEndpoint, EmptyRequ
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "You are not authorized",
|
||||
instance = "/api/v1/libraries/{id}/scan"
|
||||
instance = "/api/v1/libraries/{id}/scans"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -45,7 +45,7 @@ public class ScanLibraryEndpointSummary : Summary<ScanLibraryEndpoint, EmptyRequ
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
|
||||
instance = "/api/v1/libraries/{id}/scan"
|
||||
instance = "/api/v1/libraries/{id}/scans"
|
||||
},
|
||||
new
|
||||
{
|
||||
@@ -53,7 +53,7 @@ public class ScanLibraryEndpointSummary : Summary<ScanLibraryEndpoint, EmptyRequ
|
||||
status = 401,
|
||||
title = "Unauthorized",
|
||||
detail = "The token is invalid",
|
||||
instance = "/api/v1/libraries/{id}/scan"
|
||||
instance = "/api/v1/libraries/{id}/scans"
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -67,7 +67,7 @@ public class ScanLibraryEndpointSummary : Summary<ScanLibraryEndpoint, EmptyRequ
|
||||
title = "General.Failure",
|
||||
status = 403,
|
||||
detail = "CannotScanDisabledLibrary",
|
||||
instance = "/api/v1/libraries/{id}/scan",
|
||||
instance = "/api/v1/libraries/{id}/scans",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
},
|
||||
new
|
||||
@@ -76,7 +76,7 @@ public class ScanLibraryEndpointSummary : Summary<ScanLibraryEndpoint, EmptyRequ
|
||||
title = "General.Failure",
|
||||
status = 403,
|
||||
detail = "CannotScanLockedLibrary",
|
||||
instance = "/api/v1/libraries/{id}/scan",
|
||||
instance = "/api/v1/libraries/{id}/scans",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
},
|
||||
new
|
||||
@@ -85,7 +85,7 @@ public class ScanLibraryEndpointSummary : Summary<ScanLibraryEndpoint, EmptyRequ
|
||||
title = "General.Failure",
|
||||
status = 403,
|
||||
detail = "NotAuthorized",
|
||||
instance = "/api/v1/libraries/{id}/scan",
|
||||
instance = "/api/v1/libraries/{id}/scans",
|
||||
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public class ScanLibraryEndpointSummary : Summary<ScanLibraryEndpoint, EmptyRequ
|
||||
title = "General.NotFound",
|
||||
status = 404,
|
||||
detail = "LibraryNotFound",
|
||||
instance = "/api/v1/libraries/{id}/scan",
|
||||
instance = "/api/v1/libraries/{id}/scans",
|
||||
traceId = "00-57d15dadd702dbd4aeb5dc9b7cee68ee-9330237dbb2ce0e5-00"
|
||||
}
|
||||
);
|
||||
@@ -110,7 +110,7 @@ public class ScanLibraryEndpointSummary : Summary<ScanLibraryEndpoint, EmptyRequ
|
||||
title = "General.Validation",
|
||||
status = 422,
|
||||
detail = "OneOrMoreValidationErrorsOccurred",
|
||||
instance = "/api/v1/libraries/{id}/scan",
|
||||
instance = "/api/v1/libraries/{id}/scans",
|
||||
errors = new Dictionary<string, string[]>
|
||||
{
|
||||
{
|
||||
|
||||
+3
-3
@@ -40,8 +40,8 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
SaveMetadataInMediaDirectories: false
|
||||
);
|
||||
|
||||
RequestParam(r => r.Id, "The Id of the media library. Required.");
|
||||
RequestParam(r => r.UserId, "The Id of the user owning the media library. Required.");
|
||||
RequestParam(r => r.Id, "The unique identifier of the media library. Required.");
|
||||
RequestParam(r => r.UserId, "The unique identifier of the user owning the media library. Required.");
|
||||
RequestParam(r => r.Title, "The title of the media library. Required.");
|
||||
RequestParam(r => r.LibraryType, "The type of the media library. Required.");
|
||||
RequestParam(r => r.ContentLocations, ">The file system paths of the directories where the media library elements are located. Required.");
|
||||
@@ -52,7 +52,7 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
RequestParam(r => r.SaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional.");
|
||||
|
||||
ResponseParam<LibraryResponse>(r => r.Id, "The unique identifier of the entity.");
|
||||
ResponseParam<LibraryResponse>(r => r.UserId, "The Id of the user owning the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.UserId, "The unique identifier of the user owning the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.Title, "The title of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.LibraryType, "The type of the media library.");
|
||||
ResponseParam<LibraryResponse>(r => r.ContentLocations, "The file system paths of the directories where the media library elements are located.");
|
||||
|
||||
Reference in new issue
Block a user