mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 18:57:24 +00:00
Merge branch 'feature/add-metadata-aggregation' into feature/add-artwork-provider-and-metadata-aggregation
This commit is contained in:
commit
b47588cf83
168 files changed
+3503
-1062
No files matched your search
@@ -25,5 +25,5 @@ public record LibraryFilterDto : BaseFilterDto
|
||||
/// <summary>
|
||||
/// Whether the leading "The " prefix of a title should be ignored when computing the alpha key, or not.
|
||||
/// </summary>
|
||||
public bool IgnoreThePrefixForAlphaPicker { get; init; }
|
||||
public bool ShouldIgnoreThePrefixForAlphaPicker { get; init; }
|
||||
}
|
||||
+1
-1
@@ -63,7 +63,7 @@ public class LibraryEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets whether this media library should update the metadata of its elements from the web, or not.
|
||||
/// </summary>
|
||||
public bool DownloadMetadataFromWeb { get; init; }
|
||||
public bool CanDownloadMetadataFromWeb { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this media library should copy the downloaded metadata into the media library content locations, or not.
|
||||
|
||||
+6
-1
@@ -35,13 +35,18 @@ public class UserSettingsEntity : IStorageEntity, IAuditableEntity
|
||||
/// <summary>
|
||||
/// Gets or sets whether the "The" prefix of library item titles is ignored by the alpha picker, or not.
|
||||
/// </summary>
|
||||
public bool IgnoreThePrefixForAlphaPicker { get; set; }
|
||||
public bool ShouldIgnoreThePrefixForAlphaPicker { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the theme data served to this user is cached, or not.
|
||||
/// </summary>
|
||||
public bool IsThemeCachingEnabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.
|
||||
/// </summary>
|
||||
public bool ShouldAggregateMetadataWhenMissing { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time and date when the entity was added.
|
||||
/// </summary>
|
||||
|
||||
@@ -71,6 +71,11 @@ public interface IUnitOfWork
|
||||
/// </summary>
|
||||
ILibraryMetadataProviderConfigurationRepository LibraryMetadataProviderConfigurationRepository { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the library artwork provider configuration repository.
|
||||
/// </summary>
|
||||
IArtworkProviderConfigurationRepository ArtworkProviderConfigurationRepository { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin repository.
|
||||
/// </summary>
|
||||
@@ -97,6 +102,11 @@ public interface IUnitOfWork
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
Task SaveChangesAsync(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Detaches all the entities tracked by the unit of work, freeing the memory they occupy.
|
||||
/// </summary>
|
||||
void ClearTrackedEntities();
|
||||
|
||||
/// <summary>
|
||||
/// Begins a new database transaction.
|
||||
/// </summary>
|
||||
|
||||
+5
@@ -21,4 +21,9 @@ public class MediaSettingsDto
|
||||
/// Gets or sets the directory where media library files are stored.
|
||||
/// </summary>
|
||||
public required string LibrariesDirectory { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the directory where the media item files are stored.
|
||||
/// </summary>
|
||||
public required string BooksDirectory { get; init; }
|
||||
}
|
||||
+1
-4
@@ -1,9 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Books.Commands.AddBook;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
@@ -27,7 +24,7 @@ public static class AddMediaLibraryRequestMapping
|
||||
request.CoverImage,
|
||||
request.IsEnabled,
|
||||
request.IsLocked,
|
||||
request.DownloadMetadataFromWeb,
|
||||
request.CanDownloadMetadataFromWeb,
|
||||
request.ShouldSaveMetadataInMediaDirectories,
|
||||
request.ShouldSkipUnchangedDirectoriesDuringScan
|
||||
);
|
||||
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
@@ -29,11 +29,11 @@ public static class LibraryEntityMapping
|
||||
repositoryEntity.UserId,
|
||||
repositoryEntity.Title,
|
||||
repositoryEntity.LibraryType,
|
||||
repositoryEntity.ContentLocations.Select(location => location.Path).ToList(),
|
||||
[.. repositoryEntity.ContentLocations.Select(location => location.Path)],
|
||||
repositoryEntity.CoverImage,
|
||||
repositoryEntity.IsEnabled,
|
||||
repositoryEntity.IsLocked,
|
||||
repositoryEntity.DownloadMetadataFromWeb,
|
||||
repositoryEntity.CanDownloadMetadataFromWeb,
|
||||
repositoryEntity.ShouldSaveMetadataInMediaDirectories,
|
||||
repositoryEntity.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
repositoryEntity.CreatedOnUtc,
|
||||
@@ -59,10 +59,10 @@ public static class LibraryEntityMapping
|
||||
repositoryEntity.CoverImage,
|
||||
repositoryEntity.IsEnabled,
|
||||
repositoryEntity.IsLocked,
|
||||
repositoryEntity.DownloadMetadataFromWeb,
|
||||
repositoryEntity.CanDownloadMetadataFromWeb,
|
||||
repositoryEntity.ShouldSaveMetadataInMediaDirectories,
|
||||
repositoryEntity.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
repositoryEntity.LibraryScans.Select(libraryScan => ScanId.Create(libraryScan.Id)).ToList()
|
||||
[.. repositoryEntity.LibraryScans.Select(libraryScan => ScanId.Create(libraryScan.Id))]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,14 +25,14 @@ public static class LibraryMapping
|
||||
Title = domainEntity.Title,
|
||||
LibraryType = domainEntity.LibraryType,
|
||||
UserId = domainEntity.UserId.Value,
|
||||
ContentLocations = domainEntity.ContentLocations.Select(path => new LibraryContentLocationEntity() { Path = path.Path }).ToList(),
|
||||
ContentLocations = [.. domainEntity.ContentLocations.Select(path => new LibraryContentLocationEntity() { Path = path.Path })],
|
||||
CoverImage = domainEntity.CoverImage,
|
||||
IsEnabled = domainEntity.IsEnabled,
|
||||
IsLocked = domainEntity.IsLocked,
|
||||
DownloadMetadataFromWeb = domainEntity.DownloadMetadataFromWeb,
|
||||
CanDownloadMetadataFromWeb = domainEntity.CanDownloadMetadataFromWeb,
|
||||
ShouldSaveMetadataInMediaDirectories = domainEntity.ShouldSaveMetadataInMediaDirectories,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan = domainEntity.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
LibraryScans = domainEntity.ScanIds.Select(scanId => new LibraryScanEntity()
|
||||
LibraryScans = [.. domainEntity.ScanIds.Select(scanId => new LibraryScanEntity()
|
||||
{
|
||||
Id = scanId.Value,
|
||||
LibraryId = domainEntity.Id.Value,
|
||||
@@ -43,7 +43,7 @@ public static class LibraryMapping
|
||||
CreatedBy = default,
|
||||
CreatedOnUtc = default,
|
||||
UpdatedBy = default,
|
||||
}).ToList(),
|
||||
})],
|
||||
CreatedOnUtc = domainEntity.CreatedOnUtc,
|
||||
CreatedBy = Guid.Empty,
|
||||
UpdatedOnUtc = domainEntity.UpdatedOnUtc.HasValue ? domainEntity.UpdatedOnUtc : null,
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
@@ -27,7 +26,7 @@ public static class UpdateLibraryRequestMapping
|
||||
request.CoverImage,
|
||||
request.IsEnabled,
|
||||
request.IsLocked,
|
||||
request.DownloadMetadataFromWeb,
|
||||
request.CanDownloadMetadataFromWeb,
|
||||
request.ShouldSaveMetadataInMediaDirectories,
|
||||
request.ShouldSkipUnchangedDirectoriesDuringScan
|
||||
);
|
||||
|
||||
+4
-2
@@ -20,7 +20,9 @@ public static class UpdateUserSettingsRequestMapping
|
||||
return new UpdateUserSettingsCommand(
|
||||
request.IsPaginationEnabled,
|
||||
request.ItemsPerPage,
|
||||
request.IgnoreThePrefixForAlphaPicker,
|
||||
request.IsThemeCachingEnabled);
|
||||
request.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
request.IsThemeCachingEnabled,
|
||||
request.ShouldAggregateMetadataWhenMissing
|
||||
);
|
||||
}
|
||||
}
|
||||
+9
-5
@@ -1,7 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Contracts.Responses.UsersManagement.Settings;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate.ValueObjects;
|
||||
@@ -28,8 +28,10 @@ public static class UserSettingsEntityMapping
|
||||
UserId.Create(repositoryEntity.UserId),
|
||||
repositoryEntity.IsPaginationEnabled,
|
||||
repositoryEntity.ItemsPerPage,
|
||||
repositoryEntity.IgnoreThePrefixForAlphaPicker,
|
||||
repositoryEntity.IsThemeCachingEnabled);
|
||||
repositoryEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
repositoryEntity.IsThemeCachingEnabled,
|
||||
repositoryEntity.ShouldAggregateMetadataWhenMissing
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -43,7 +45,9 @@ public static class UserSettingsEntityMapping
|
||||
repositoryEntity.UserId,
|
||||
repositoryEntity.IsPaginationEnabled,
|
||||
repositoryEntity.ItemsPerPage,
|
||||
repositoryEntity.IgnoreThePrefixForAlphaPicker,
|
||||
repositoryEntity.IsThemeCachingEnabled);
|
||||
repositoryEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
repositoryEntity.IsThemeCachingEnabled,
|
||||
repositoryEntity.ShouldAggregateMetadataWhenMissing
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,9 @@ public static class UserSettingsMapping
|
||||
UserId = domainEntity.UserId.Value,
|
||||
IsPaginationEnabled = domainEntity.IsPaginationEnabled,
|
||||
ItemsPerPage = domainEntity.ItemsPerPage,
|
||||
IgnoreThePrefixForAlphaPicker = domainEntity.IgnoreThePrefixForAlphaPicker,
|
||||
IsThemeCachingEnabled = domainEntity.IsThemeCachingEnabled
|
||||
ShouldIgnoreThePrefixForAlphaPicker = domainEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
IsThemeCachingEnabled = domainEntity.IsThemeCachingEnabled,
|
||||
ShouldAggregateMetadataWhenMissing = domainEntity.ShouldAggregateMetadataWhenMissing
|
||||
};
|
||||
}
|
||||
|
||||
@@ -40,7 +41,9 @@ public static class UserSettingsMapping
|
||||
domainEntity.UserId.Value,
|
||||
domainEntity.IsPaginationEnabled,
|
||||
domainEntity.ItemsPerPage,
|
||||
domainEntity.IgnoreThePrefixForAlphaPicker,
|
||||
domainEntity.IsThemeCachingEnabled);
|
||||
domainEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
domainEntity.IsThemeCachingEnabled,
|
||||
domainEntity.ShouldAggregateMetadataWhenMissing
|
||||
);
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
@@ -15,7 +14,7 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
|
||||
/// <param name="CoverImage">The path of the image file used as the cover for the library.</param>
|
||||
/// <param name="IsEnabled">Whether this media library is enabled or not. A disabled media library is never shown or changed.</param>
|
||||
/// <param name="IsLocked">Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated.</param>
|
||||
/// <param name="DownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="CanDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="ShouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="ShouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
@@ -26,7 +25,7 @@ public record AddLibraryCommand(
|
||||
string? CoverImage,
|
||||
bool IsEnabled,
|
||||
bool IsLocked,
|
||||
bool DownloadMetadataFromWeb,
|
||||
bool CanDownloadMetadataFromWeb,
|
||||
bool ShouldSaveMetadataInMediaDirectories,
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan
|
||||
) : ICommand;
|
||||
+5
-6
@@ -1,8 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DomainEvents;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
@@ -10,14 +8,15 @@ using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
@@ -113,7 +112,7 @@ public class AddLibraryCommandHandler : ICommandHandler<AddLibraryCommand, Resul
|
||||
command.CoverImage,
|
||||
command.IsEnabled,
|
||||
command.IsLocked,
|
||||
command.DownloadMetadataFromWeb,
|
||||
command.CanDownloadMetadataFromWeb,
|
||||
command.ShouldSaveMetadataInMediaDirectories,
|
||||
command.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
[]
|
||||
|
||||
+2
-2
@@ -17,7 +17,7 @@ namespace Lumina.Application.Core.MediaLibrary.Management.Commands.UpdateLibrary
|
||||
/// <param name="CoverImage">The path of the image file used as the cover for the library.</param>
|
||||
/// <param name="IsEnabled">Whether this media library is enabled or not. A disabled media library is never shown or changed.</param>
|
||||
/// <param name="IsLocked">Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated.</param>
|
||||
/// <param name="DownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="CanDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="ShouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="ShouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
@@ -30,7 +30,7 @@ public record UpdateLibraryCommand(
|
||||
string? CoverImage,
|
||||
bool IsEnabled,
|
||||
bool IsLocked,
|
||||
bool DownloadMetadataFromWeb,
|
||||
bool CanDownloadMetadataFromWeb,
|
||||
bool ShouldSaveMetadataInMediaDirectories,
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan
|
||||
) : ICommand;
|
||||
+6
-7
@@ -1,8 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.MediaLibrary;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.DomainEvents;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
@@ -11,16 +9,17 @@ using Lumina.Application.Common.Infrastructure.Authorization.Policies.LibraryOwn
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.Authorization;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.PhotoLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -127,10 +126,10 @@ public class UpdateLibraryCommandHandler : ICommandHandler<UpdateLibraryCommand,
|
||||
command.CoverImage,
|
||||
command.IsEnabled,
|
||||
command.IsLocked,
|
||||
command.DownloadMetadataFromWeb,
|
||||
command.CanDownloadMetadataFromWeb,
|
||||
command.ShouldSaveMetadataInMediaDirectories,
|
||||
command.ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
getLibraryResult.Value.LibraryScans.Select(libraryScan => ScanId.Create(libraryScan.Id)).ToList()
|
||||
[.. getLibraryResult.Value.LibraryScans.Select(libraryScan => ScanId.Create(libraryScan.Id))]
|
||||
);
|
||||
if (createLibraryResult.IsFailure)
|
||||
return createLibraryResult.Errors;
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class LibraryScanQueuedDomainEventHandler : IDomainEventHandler<LibrarySc
|
||||
|
||||
// start the media library scan
|
||||
Result<Success> startScanResult = await _mediaLibraryScanningService.StartScanAsync(
|
||||
libraryScanDomainResult.Value, getLibraryScanResult.Value.Library.LibraryType, getLibraryScanResult.Value.Library.DownloadMetadataFromWeb, cancellationToken).ConfigureAwait(false);
|
||||
libraryScanDomainResult.Value, getLibraryScanResult.Value.Library.LibraryType, cancellationToken).ConfigureAwait(false);
|
||||
if (startScanResult.IsFailure)
|
||||
throw new EventualConsistencyException(startScanResult.FirstError, startScanResult.Errors);
|
||||
|
||||
|
||||
+24
-3
@@ -1,15 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Plugins;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization.Policies.LibraryOwnership;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.Plugins.Commands.ReorderLibraryMetadataProviders;
|
||||
@@ -20,15 +23,21 @@ namespace Lumina.Application.Core.Plugins.Commands.ReorderLibraryMetadataProvide
|
||||
public class ReorderLibraryMetadataProvidersCommandHandler : ICommandHandler<ReorderLibraryMetadataProvidersCommand, Result<Success>>
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
private readonly IValidator<ReorderLibraryMetadataProvidersCommand> _validator;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReorderLibraryMetadataProvidersCommandHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="authorizationService">Injected service for authorization related functionality.</param>
|
||||
/// <param name="currentUserService">Injected service to retrieve the current user information.</param>
|
||||
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
|
||||
/// <param name="validator">Injected validator for application validation rules.</param>
|
||||
public ReorderLibraryMetadataProvidersCommandHandler(IUnitOfWork unitOfWork, IValidator<ReorderLibraryMetadataProvidersCommand> validator)
|
||||
public ReorderLibraryMetadataProvidersCommandHandler(IAuthorizationService authorizationService, ICurrentUserService currentUserService, IUnitOfWork unitOfWork, IValidator<ReorderLibraryMetadataProvidersCommand> validator)
|
||||
{
|
||||
_authorizationService = authorizationService;
|
||||
_currentUserService = currentUserService;
|
||||
_unitOfWork = unitOfWork;
|
||||
_validator = validator;
|
||||
}
|
||||
@@ -47,6 +56,18 @@ public class ReorderLibraryMetadataProvidersCommandHandler : ICommandHandler<Reo
|
||||
if (validationResult.Count > 0)
|
||||
return validationResult;
|
||||
|
||||
// an authenticated request must always carry a user identity
|
||||
Guid? currentUserId = _currentUserService.UserId;
|
||||
if (currentUserId is null)
|
||||
return ApplicationErrors.Authorization.NotAuthorized;
|
||||
Guid userId = currentUserId.Value;
|
||||
|
||||
// admins can reorder the metadata providers of any library; for everyone else, only their own libraries
|
||||
bool canAccessLibrary = await _authorizationService.EvaluatePolicyAsync<ILibraryOwnershipPolicy>(
|
||||
userId, new LibraryOwnershipPolicyContext(command.LibraryId), cancellationToken).ConfigureAwait(false);
|
||||
if (!canAccessLibrary)
|
||||
return ApplicationErrors.Authorization.NotAuthorized;
|
||||
|
||||
Result<IReadOnlyList<LibraryMetadataProviderConfigurationEntity>> getConfigurationsResult = await _unitOfWork.LibraryMetadataProviderConfigurationRepository.GetByLibraryIdAsync(command.LibraryId, cancellationToken).ConfigureAwait(false);
|
||||
if (getConfigurationsResult.IsFailure)
|
||||
return getConfigurationsResult.Errors;
|
||||
|
||||
+3
@@ -2,6 +2,7 @@
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Common.Utilities;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.Plugins.Commands.ReorderLibraryMetadataProviders;
|
||||
@@ -18,6 +19,8 @@ public class ReorderLibraryMetadataProvidersCommandValidator : AbstractValidator
|
||||
{
|
||||
RuleFor(command => command.LibraryId)
|
||||
.NotEmpty()
|
||||
.WithError(Errors.Plugins.LibraryIdCannotBeEmpty)
|
||||
.Must(id => id != Guid.Empty)
|
||||
.WithError(Errors.Plugins.LibraryIdCannotBeEmpty);
|
||||
|
||||
RuleFor(command => command.PluginIds)
|
||||
|
||||
+24
-3
@@ -1,15 +1,18 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Plugins;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization.Policies.LibraryOwnership;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.Plugins.Commands.SetLibraryMetadataProviderEnabled;
|
||||
@@ -20,15 +23,21 @@ namespace Lumina.Application.Core.Plugins.Commands.SetLibraryMetadataProviderEna
|
||||
public class SetLibraryMetadataProviderEnabledCommandHandler : ICommandHandler<SetLibraryMetadataProviderEnabledCommand, Result<Success>>
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
private readonly IValidator<SetLibraryMetadataProviderEnabledCommand> _validator;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SetLibraryMetadataProviderEnabledCommandHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="authorizationService">Injected service for authorization related functionality.</param>
|
||||
/// <param name="currentUserService">Injected service to retrieve the current user information.</param>
|
||||
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
|
||||
/// <param name="validator">Injected validator for application validation rules.</param>
|
||||
public SetLibraryMetadataProviderEnabledCommandHandler(IUnitOfWork unitOfWork, IValidator<SetLibraryMetadataProviderEnabledCommand> validator)
|
||||
public SetLibraryMetadataProviderEnabledCommandHandler(IAuthorizationService authorizationService, ICurrentUserService currentUserService, IUnitOfWork unitOfWork, IValidator<SetLibraryMetadataProviderEnabledCommand> validator)
|
||||
{
|
||||
_authorizationService = authorizationService;
|
||||
_currentUserService = currentUserService;
|
||||
_unitOfWork = unitOfWork;
|
||||
_validator = validator;
|
||||
}
|
||||
@@ -47,6 +56,18 @@ public class SetLibraryMetadataProviderEnabledCommandHandler : ICommandHandler<S
|
||||
if (validationResult.Count > 0)
|
||||
return validationResult;
|
||||
|
||||
// an authenticated request must always carry a user identity
|
||||
Guid? currentUserId = _currentUserService.UserId;
|
||||
if (currentUserId is null)
|
||||
return ApplicationErrors.Authorization.NotAuthorized;
|
||||
Guid userId = currentUserId.Value;
|
||||
|
||||
// admins can configure the metadata providers of any library; for everyone else, only their own libraries
|
||||
bool canAccessLibrary = await _authorizationService.EvaluatePolicyAsync<ILibraryOwnershipPolicy>(
|
||||
userId, new LibraryOwnershipPolicyContext(command.LibraryId), cancellationToken).ConfigureAwait(false);
|
||||
if (!canAccessLibrary)
|
||||
return ApplicationErrors.Authorization.NotAuthorized;
|
||||
|
||||
Result<LibraryMetadataProviderConfigurationEntity?> getConfigurationResult = await _unitOfWork.LibraryMetadataProviderConfigurationRepository.GetByLibraryAndPluginIdAsync(command.LibraryId, command.PluginId, cancellationToken).ConfigureAwait(false);
|
||||
if (getConfigurationResult.IsFailure)
|
||||
return getConfigurationResult.Errors;
|
||||
|
||||
+5
@@ -2,6 +2,7 @@
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Common.Utilities;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.Plugins.Commands.SetLibraryMetadataProviderEnabled;
|
||||
@@ -18,10 +19,14 @@ public class SetLibraryMetadataProviderEnabledCommandValidator : AbstractValidat
|
||||
{
|
||||
RuleFor(command => command.LibraryId)
|
||||
.NotEmpty()
|
||||
.WithError(Errors.Plugins.LibraryIdCannotBeEmpty)
|
||||
.Must(id => id != Guid.Empty)
|
||||
.WithError(Errors.Plugins.LibraryIdCannotBeEmpty);
|
||||
|
||||
RuleFor(command => command.PluginId)
|
||||
.NotEmpty()
|
||||
.WithError(Errors.Plugins.PluginIdCannotBeEmpty)
|
||||
.Must(id => id != Guid.Empty)
|
||||
.WithError(Errors.Plugins.PluginIdCannotBeEmpty);
|
||||
}
|
||||
}
|
||||
+3
@@ -2,6 +2,7 @@
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Common.Utilities;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.Plugins.Commands.UpdatePluginSettings;
|
||||
@@ -18,6 +19,8 @@ public class UpdatePluginSettingsCommandValidator : AbstractValidator<UpdatePlug
|
||||
{
|
||||
RuleFor(command => command.PluginId)
|
||||
.NotEmpty()
|
||||
.WithError(Errors.Plugins.PluginIdCannotBeEmpty)
|
||||
.Must(id => id != Guid.Empty)
|
||||
.WithError(Errors.Plugins.PluginIdCannotBeEmpty);
|
||||
}
|
||||
}
|
||||
+32
-3
@@ -1,16 +1,20 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Plugins;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization;
|
||||
using Lumina.Application.Common.Infrastructure.Authorization.Policies.LibraryOwnership;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Common.Mapping.Plugins;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.Plugins.Queries.GetLibraryMetadataProviders;
|
||||
@@ -21,14 +25,23 @@ namespace Lumina.Application.Core.Plugins.Queries.GetLibraryMetadataProviders;
|
||||
public class GetLibraryMetadataProvidersQueryHandler : IQueryHandler<GetLibraryMetadataProvidersQuery, Result<IReadOnlyList<LibraryMetadataProviderResponse>>>
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly ICurrentUserService _currentUserService;
|
||||
private readonly IValidator<GetLibraryMetadataProvidersQuery> _validator;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryMetadataProvidersQueryHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="authorizationService">Injected service for authorization related functionality.</param>
|
||||
/// <param name="currentUserService">Injected service to retrieve the current user information.</param>
|
||||
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
|
||||
public GetLibraryMetadataProvidersQueryHandler(IUnitOfWork unitOfWork)
|
||||
/// <param name="validator">Injected validator for application validation rules.</param>
|
||||
public GetLibraryMetadataProvidersQueryHandler(IAuthorizationService authorizationService, ICurrentUserService currentUserService, IUnitOfWork unitOfWork, IValidator<GetLibraryMetadataProvidersQuery> validator)
|
||||
{
|
||||
_authorizationService = authorizationService;
|
||||
_currentUserService = currentUserService;
|
||||
_unitOfWork = unitOfWork;
|
||||
_validator = validator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -41,6 +54,22 @@ public class GetLibraryMetadataProvidersQueryHandler : IQueryHandler<GetLibraryM
|
||||
/// </returns>
|
||||
public async Task<Result<IReadOnlyList<LibraryMetadataProviderResponse>>> HandleAsync(GetLibraryMetadataProvidersQuery query, CancellationToken cancellationToken)
|
||||
{
|
||||
List<Error> validationResult = _validator.Validate(query);
|
||||
if (validationResult.Count > 0)
|
||||
return validationResult;
|
||||
|
||||
// an authenticated request must always carry a user identity
|
||||
Guid? currentUserId = _currentUserService.UserId;
|
||||
if (currentUserId is null)
|
||||
return ApplicationErrors.Authorization.NotAuthorized;
|
||||
Guid userId = currentUserId.Value;
|
||||
|
||||
// admins can read the metadata providers of any library; for everyone else, only their own libraries
|
||||
bool canAccessLibrary = await _authorizationService.EvaluatePolicyAsync<ILibraryOwnershipPolicy>(
|
||||
userId, new LibraryOwnershipPolicyContext(query.LibraryId), cancellationToken).ConfigureAwait(false);
|
||||
if (!canAccessLibrary)
|
||||
return ApplicationErrors.Authorization.NotAuthorized;
|
||||
|
||||
Result<IReadOnlyList<LibraryMetadataProviderConfigurationEntity>> getConfigurationsResult = await _unitOfWork.LibraryMetadataProviderConfigurationRepository.GetByLibraryIdAsync(query.LibraryId, cancellationToken).ConfigureAwait(false);
|
||||
if (getConfigurationsResult.IsFailure)
|
||||
return getConfigurationsResult.Errors;
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Common.Utilities;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.Plugins.Queries.GetLibraryMetadataProviders;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for <see cref="GetLibraryMetadataProvidersQuery"/>.
|
||||
/// </summary>
|
||||
public class GetLibraryMetadataProvidersQueryValidator : AbstractValidator<GetLibraryMetadataProvidersQuery>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryMetadataProvidersQueryValidator"/> class.
|
||||
/// </summary>
|
||||
public GetLibraryMetadataProvidersQueryValidator()
|
||||
{
|
||||
RuleFor(query => query.LibraryId)
|
||||
.NotEmpty()
|
||||
.WithError(Errors.Plugins.LibraryIdCannotBeEmpty)
|
||||
.Must(id => id != Guid.Empty)
|
||||
.WithError(Errors.Plugins.LibraryIdCannotBeEmpty);
|
||||
}
|
||||
}
|
||||
+10
-3
@@ -1,13 +1,13 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Plugins;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Infrastructure.Plugins;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Common.Mapping.Plugins;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Plugins.Contracts.Core.Plugins;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -24,16 +24,19 @@ public class GetPluginSettingsQueryHandler : IQueryHandler<GetPluginSettingsQuer
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly IPluginManager _pluginManager;
|
||||
private readonly IValidator<GetPluginSettingsQuery> _validator;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetPluginSettingsQueryHandler"/> class.
|
||||
/// </summary>
|
||||
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
|
||||
/// <param name="pluginManager">Injected manager of the plugins loaded by the host application.</param>
|
||||
public GetPluginSettingsQueryHandler(IUnitOfWork unitOfWork, IPluginManager pluginManager)
|
||||
/// <param name="validator">Injected validator for application validation rules.</param>
|
||||
public GetPluginSettingsQueryHandler(IUnitOfWork unitOfWork, IPluginManager pluginManager, IValidator<GetPluginSettingsQuery> validator)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
_pluginManager = pluginManager;
|
||||
_validator = validator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -46,6 +49,10 @@ public class GetPluginSettingsQueryHandler : IQueryHandler<GetPluginSettingsQuer
|
||||
/// </returns>
|
||||
public async Task<Result<PluginSettingsResponse>> HandleAsync(GetPluginSettingsQuery query, CancellationToken cancellationToken)
|
||||
{
|
||||
List<Error> validationResult = _validator.Validate(query);
|
||||
if (validationResult.Count > 0)
|
||||
return validationResult;
|
||||
|
||||
Result<PluginEntity?> getPluginResult = await _unitOfWork.PluginRepository.GetByIdAsync(query.PluginId, cancellationToken).ConfigureAwait(false);
|
||||
if (getPluginResult.IsFailure)
|
||||
return getPluginResult.Errors;
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Common.Utilities;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Core.Plugins.Queries.GetPluginSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Validates the needed validation rules for <see cref="GetPluginSettingsQuery"/>.
|
||||
/// </summary>
|
||||
public class GetPluginSettingsQueryValidator : AbstractValidator<GetPluginSettingsQuery>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetPluginSettingsQueryValidator"/> class.
|
||||
/// </summary>
|
||||
public GetPluginSettingsQueryValidator()
|
||||
{
|
||||
RuleFor(query => query.PluginId)
|
||||
.NotEmpty()
|
||||
.WithError(Errors.Plugins.PluginIdCannotBeEmpty)
|
||||
.Must(id => id != Guid.Empty)
|
||||
.WithError(Errors.Plugins.PluginIdCannotBeEmpty);
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -9,11 +9,13 @@ namespace Lumina.Application.Core.UsersManagement.Settings.Commands.UpdateUserSe
|
||||
/// </summary>
|
||||
/// <param name="IsPaginationEnabled">Whether pagination is enabled for the user, or not.</param>
|
||||
/// <param name="ItemsPerPage">The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="IgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="ShouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="IsThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
||||
/// <param name="ShouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||
public record UpdateUserSettingsCommand(
|
||||
bool IsPaginationEnabled,
|
||||
int ItemsPerPage,
|
||||
bool IgnoreThePrefixForAlphaPicker,
|
||||
bool IsThemeCachingEnabled
|
||||
bool ShouldIgnoreThePrefixForAlphaPicker,
|
||||
bool IsThemeCachingEnabled,
|
||||
bool ShouldAggregateMetadataWhenMissing
|
||||
) : ICommand;
|
||||
+7
-6
@@ -1,13 +1,12 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Application.Common.CQRS;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Users;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Errors;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Validation;
|
||||
using Lumina.Application.Common.Mapping.UsersManagement.Users;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate;
|
||||
using System;
|
||||
@@ -72,8 +71,9 @@ public class UpdateUserSettingsCommandHandler : ICommandHandler<UpdateUserSettin
|
||||
UserId.Create(userId),
|
||||
command.IsPaginationEnabled,
|
||||
command.ItemsPerPage,
|
||||
command.IgnoreThePrefixForAlphaPicker,
|
||||
command.IsThemeCachingEnabled);
|
||||
command.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
command.IsThemeCachingEnabled,
|
||||
command.ShouldAggregateMetadataWhenMissing);
|
||||
if (createSettingsResult.IsFailure)
|
||||
return createSettingsResult.Errors;
|
||||
|
||||
@@ -91,8 +91,9 @@ public class UpdateUserSettingsCommandHandler : ICommandHandler<UpdateUserSettin
|
||||
Result<Updated> updateSettingsResult = toDomainEntityResult.Value.UpdateSettings(
|
||||
command.IsPaginationEnabled,
|
||||
command.ItemsPerPage,
|
||||
command.IgnoreThePrefixForAlphaPicker,
|
||||
command.IsThemeCachingEnabled);
|
||||
command.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
command.IsThemeCachingEnabled,
|
||||
command.ShouldAggregateMetadataWhenMissing);
|
||||
if (updateSettingsResult.IsFailure)
|
||||
return updateSettingsResult.Errors;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
/// <param name="CoverImage">The path of the image file used as the cover for the library. Optional.</param>
|
||||
/// <param name="IsEnabled">Whether this media library is enabled or not. A disabled media library is never shown or changed. Optional.</param>
|
||||
/// <param name="IsLocked">Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. Optional.</param>
|
||||
/// <param name="DownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not. Optional.</param>
|
||||
/// <param name="CanDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not. Optional.</param>
|
||||
/// <param name="ShouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional.</param>
|
||||
/// <param name="ShouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
@@ -24,7 +24,7 @@ public record AddLibraryRequest(
|
||||
string? CoverImage,
|
||||
bool IsEnabled,
|
||||
bool IsLocked,
|
||||
bool DownloadMetadataFromWeb,
|
||||
bool CanDownloadMetadataFromWeb,
|
||||
bool ShouldSaveMetadataInMediaDirectories,
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan
|
||||
);
|
||||
@@ -1,8 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
@@ -18,7 +16,7 @@ namespace Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
/// <param name="CoverImage">The path of the image file used as the cover for the library. Optional.</param>
|
||||
/// <param name="IsEnabled">Whether this media library is enabled or not. A disabled media library is never shown or changed. Optional.</param>
|
||||
/// <param name="IsLocked">Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. Optional.</param>
|
||||
/// <param name="DownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not. Optional.</param>
|
||||
/// <param name="CanDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not. Optional.</param>
|
||||
/// <param name="ShouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.
|
||||
/// <param name="ShouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
@@ -31,7 +29,7 @@ public record class UpdateLibraryRequest(
|
||||
string? CoverImage,
|
||||
bool IsEnabled,
|
||||
bool IsLocked,
|
||||
bool DownloadMetadataFromWeb,
|
||||
bool CanDownloadMetadataFromWeb,
|
||||
bool ShouldSaveMetadataInMediaDirectories,
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan
|
||||
);
|
||||
@@ -9,12 +9,14 @@ namespace Lumina.Contracts.Requests.UsersManagement.Settings;
|
||||
/// </summary>
|
||||
/// <param name="IsPaginationEnabled">Whether pagination is enabled for the user, or not. Required.</param>
|
||||
/// <param name="ItemsPerPage">The number of library items displayed per page when pagination is enabled. Required.</param>
|
||||
/// <param name="IgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not. Required.</param>
|
||||
/// <param name="ShouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not. Required.</param>
|
||||
/// <param name="IsThemeCachingEnabled">Whether the theme data served to this user is cached, or not. Required.</param>
|
||||
/// <param name="ShouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not. Required.</param>
|
||||
[DebuggerDisplay("IsPaginationEnabled: {IsPaginationEnabled}; ItemsPerPage: {ItemsPerPage}")]
|
||||
public sealed record UpdateUserSettingsRequest(
|
||||
bool IsPaginationEnabled,
|
||||
int ItemsPerPage,
|
||||
bool IgnoreThePrefixForAlphaPicker,
|
||||
bool IsThemeCachingEnabled
|
||||
bool ShouldIgnoreThePrefixForAlphaPicker,
|
||||
bool IsThemeCachingEnabled,
|
||||
bool ShouldAggregateMetadataWhenMissing
|
||||
);
|
||||
@@ -16,6 +16,11 @@ namespace Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
/// <param name="LibraryType">The type of the media library.</param>
|
||||
/// <param name="ContentLocations">The file system paths of the directories where the media library elements are located.</param>
|
||||
/// <param name="CoverImage">The path of the image file used as the cover for the library.</param>
|
||||
/// <param name="IsEnabled">Whether the media library is enabled or not. A disabled media library is never shown or changed.</param>
|
||||
/// <param name="IsLocked">Whether the media library is locked or not. A locked media library is displayed, but is never changed or updated.</param>
|
||||
/// <param name="CanDownloadMetadataFromWeb">Whether the media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="ShouldSaveMetadataInMediaDirectories">Whether the media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="ShouldSkipUnchangedDirectoriesDuringScan">Whether the media library should skip the directories whose contents have not changed since the last scan, during the scan.</param>
|
||||
/// <param name="CreatedOnUtc">The date and time when the library was created.</param>
|
||||
/// <param name="UpdatedOnUtc">The optional date and time when the library was updated.</param>
|
||||
[DebuggerDisplay("Title: {Title}")]
|
||||
@@ -28,7 +33,7 @@ public record LibraryResponse(
|
||||
string? CoverImage,
|
||||
bool IsEnabled,
|
||||
bool IsLocked,
|
||||
bool DownloadMetadataFromWeb,
|
||||
bool CanDownloadMetadataFromWeb,
|
||||
bool ShouldSaveMetadataInMediaDirectories,
|
||||
bool ShouldSkipUnchangedDirectoriesDuringScan,
|
||||
DateTime CreatedOnUtc,
|
||||
|
||||
@@ -11,13 +11,15 @@ namespace Lumina.Contracts.Responses.UsersManagement.Settings;
|
||||
/// <param name="UserId">The unique identifier of the user that owns these settings.</param>
|
||||
/// <param name="IsPaginationEnabled">Whether pagination is enabled for the user, or not.</param>
|
||||
/// <param name="ItemsPerPage">The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="IgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="ShouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="IsThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
||||
/// <param name="ShouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||
[DebuggerDisplay("UserId: {UserId}")]
|
||||
public sealed record UserSettingsResponse(
|
||||
Guid UserId,
|
||||
bool IsPaginationEnabled,
|
||||
int ItemsPerPage,
|
||||
bool IgnoreThePrefixForAlphaPicker,
|
||||
bool IsThemeCachingEnabled
|
||||
bool ShouldIgnoreThePrefixForAlphaPicker,
|
||||
bool IsThemeCachingEnabled,
|
||||
bool ShouldAggregateMetadataWhenMissing
|
||||
);
|
||||
@@ -46,7 +46,7 @@ public class LibraryConfiguration : IEntityTypeConfiguration<LibraryEntity>
|
||||
builder.Property(library => library.IsLocked)
|
||||
.HasColumnOrder(5);
|
||||
|
||||
builder.Property(library => library.DownloadMetadataFromWeb)
|
||||
builder.Property(library => library.CanDownloadMetadataFromWeb)
|
||||
.HasDefaultValue(true)
|
||||
.HasColumnOrder(6);
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.DataAccess.Common.Configuration;
|
||||
@@ -43,10 +42,14 @@ public class UserSettingsConfiguration : IEntityTypeConfiguration<UserSettingsEn
|
||||
.IsRequired()
|
||||
.HasColumnOrder(3);
|
||||
|
||||
builder.Property(settings => settings.IgnoreThePrefixForAlphaPicker)
|
||||
builder.Property(settings => settings.ShouldIgnoreThePrefixForAlphaPicker)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(4);
|
||||
|
||||
builder.Property(settings => settings.ShouldAggregateMetadataWhenMissing)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(10);
|
||||
|
||||
builder.Property(settings => settings.IsThemeCachingEnabled)
|
||||
.IsRequired()
|
||||
.HasColumnOrder(9);
|
||||
|
||||
@@ -132,7 +132,7 @@ internal sealed class BookRepository : IBookRepository
|
||||
booksQuery = booksQuery.Where(filterSpecification.ToExpression());
|
||||
|
||||
// apply sorting based on the specified sortBy and sortOrder parameters
|
||||
booksQuery = ApplySorting(booksQuery, sortBy, sortOrder ?? SortOrder.Ascending, libraryFilter.IgnoreThePrefixForAlphaPicker);
|
||||
booksQuery = ApplySorting(booksQuery, sortBy, sortOrder ?? SortOrder.Ascending, libraryFilter.ShouldIgnoreThePrefixForAlphaPicker);
|
||||
|
||||
// if no pagination was requested, return all the books of the library
|
||||
if (paginationData is null)
|
||||
@@ -261,8 +261,8 @@ internal sealed class BookRepository : IBookRepository
|
||||
/// <param name="booksQuery">The query to sort.</param>
|
||||
/// <param name="sortBy">The field to sort by (case-insensitive).</param>
|
||||
/// <param name="sortOrder">The direction of the sorting.</param>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">Whether a leading "the " prefix of a title is ignored when deriving the title sort key, or not.</param>
|
||||
private static IOrderedQueryable<BookEntity> ApplySorting(IQueryable<BookEntity> booksQuery, string? sortBy, SortOrder sortOrder, bool ignoreThePrefixForAlphaPicker)
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether a leading "the " prefix of a title is ignored when deriving the title sort key, or not.</param>
|
||||
private static IOrderedQueryable<BookEntity> ApplySorting(IQueryable<BookEntity> booksQuery, string? sortBy, SortOrder sortOrder, bool shouldIgnoreThePrefixForAlphaPicker)
|
||||
{
|
||||
return sortBy?.ToLower() switch
|
||||
{
|
||||
@@ -276,8 +276,8 @@ internal sealed class BookRepository : IBookRepository
|
||||
? booksQuery.OrderByDescending(book => book.MetadataProvider)
|
||||
: booksQuery.OrderBy(book => book.MetadataProvider),
|
||||
_ => sortOrder == SortOrder.Descending
|
||||
? booksQuery.OrderByDescending(BuildTitleSortKey(ignoreThePrefixForAlphaPicker))
|
||||
: booksQuery.OrderBy(BuildTitleSortKey(ignoreThePrefixForAlphaPicker)),
|
||||
? booksQuery.OrderByDescending(BuildTitleSortKey(shouldIgnoreThePrefixForAlphaPicker))
|
||||
: booksQuery.OrderBy(BuildTitleSortKey(shouldIgnoreThePrefixForAlphaPicker)),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -286,9 +286,9 @@ internal sealed class BookRepository : IBookRepository
|
||||
/// the title lowercased, falling back to the original title when the title is <see langword="null"/> or empty, and optionally
|
||||
/// stripped of a leading "the " prefix.
|
||||
/// </summary>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">Whether a leading "the " prefix of a title is ignored when deriving the title sort key, or not.</param>
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether a leading "the " prefix of a title is ignored when deriving the title sort key, or not.</param>
|
||||
/// <returns>An expression that evaluates to the title sort key of a book.</returns>
|
||||
private static Expression<Func<BookEntity, string>> BuildTitleSortKey(bool ignoreThePrefixForAlphaPicker)
|
||||
private static Expression<Func<BookEntity, string>> BuildTitleSortKey(bool shouldIgnoreThePrefixForAlphaPicker)
|
||||
{
|
||||
ParameterExpression book = Expression.Parameter(typeof(BookEntity), "book");
|
||||
|
||||
@@ -306,7 +306,7 @@ internal sealed class BookRepository : IBookRepository
|
||||
|
||||
// when ignoring the "The " prefix, strip a leading "the " from the lowercased title
|
||||
Expression effectiveTitle = lowerTitle;
|
||||
if (ignoreThePrefixForAlphaPicker)
|
||||
if (shouldIgnoreThePrefixForAlphaPicker)
|
||||
{
|
||||
MethodCallExpression startsWithThe = Expression.Call(lowerTitle, s_startsWithMethod, Expression.Constant("the "));
|
||||
MethodCallExpression strippedTitle = Expression.Call(lowerTitle, s_substringMethod, Expression.Constant(4));
|
||||
@@ -332,7 +332,7 @@ internal sealed class BookRepository : IBookRepository
|
||||
// include the alpha key filter, if provided
|
||||
if (libraryFilter.FilterAlphaKey is not null)
|
||||
{
|
||||
BookAlphaFilterSpecification alphaFilterSpecification = new(libraryFilter.FilterAlphaKey, libraryFilter.IgnoreThePrefixForAlphaPicker);
|
||||
BookAlphaFilterSpecification alphaFilterSpecification = new(libraryFilter.FilterAlphaKey, libraryFilter.ShouldIgnoreThePrefixForAlphaPicker);
|
||||
filterSpecification = filterSpecification is null
|
||||
? alphaFilterSpecification
|
||||
: filterSpecification.And(alphaFilterSpecification);
|
||||
|
||||
+5
-5
@@ -23,17 +23,17 @@ internal sealed class BookAlphaFilterSpecification : FilterSpecification<BookEnt
|
||||
.GetMethod(nameof(SqliteDbFunctionsExtensions.Glob), [typeof(DbFunctions), typeof(string), typeof(string)])!;
|
||||
|
||||
private readonly string? _filterAlphaKey;
|
||||
private readonly bool _ignoreThePrefixForAlphaPicker;
|
||||
private readonly bool _shouldIgnoreThePrefixForAlphaPicker;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BookAlphaFilterSpecification"/> class.
|
||||
/// </summary>
|
||||
/// <param name="filterAlphaKey">The alpha key to filter by. A single ASCII letter, <see cref="LibraryItemAlphaKeys.NUMBER"/>, or <see cref="LibraryItemAlphaKeys.SYMBOL"/>.</param>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">Whether the leading "The " prefix of a title should be ignored when computing the alpha key, or not.</param>
|
||||
public BookAlphaFilterSpecification(string? filterAlphaKey, bool ignoreThePrefixForAlphaPicker)
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the leading "The " prefix of a title should be ignored when computing the alpha key, or not.</param>
|
||||
public BookAlphaFilterSpecification(string? filterAlphaKey, bool shouldIgnoreThePrefixForAlphaPicker)
|
||||
{
|
||||
_filterAlphaKey = filterAlphaKey;
|
||||
_ignoreThePrefixForAlphaPicker = ignoreThePrefixForAlphaPicker;
|
||||
_shouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -82,7 +82,7 @@ internal sealed class BookAlphaFilterSpecification : FilterSpecification<BookEnt
|
||||
|
||||
// when ignoring the "The " prefix, strip a leading "the " from the lowercased title
|
||||
Expression effectiveTitle = lowerTitle;
|
||||
if (_ignoreThePrefixForAlphaPicker)
|
||||
if (_shouldIgnoreThePrefixForAlphaPicker)
|
||||
{
|
||||
MethodCallExpression startsWithThe = Expression.Call(lowerTitle, s_startsWithMethod, Expression.Constant("the "));
|
||||
MethodCallExpression strippedTitle = Expression.Call(lowerTitle, s_substringMethod, Expression.Constant(4));
|
||||
|
||||
@@ -33,6 +33,7 @@ public class LuminaDbContext : DbContext
|
||||
public virtual DbSet<RolePermissionEntity> RolePermissions { get; set; } = null!;
|
||||
public virtual DbSet<PluginEntity> Plugins { get; set; } = null!;
|
||||
public virtual DbSet<LibraryMetadataProviderConfigurationEntity> LibraryMetadataProviderConfigurations { get; set; } = null!;
|
||||
public virtual DbSet<LibraryArtworkProviderConfigurationEntity> LibraryArtworkProviderConfigurations { get; set; } = null!;
|
||||
public virtual DbSet<ThemeEntity> Themes { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -39,6 +39,7 @@ public class UnitOfWork : IUnitOfWork, IDisposable
|
||||
private ILibraryScanSnapshotRepository? _libraryScanSnapshotRepository;
|
||||
private ILibraryScanStagingResultsRepository? _libraryScanStagingResultsRepository;
|
||||
private ILibraryMetadataProviderConfigurationRepository? _libraryMetadataProviderConfigurationRepository;
|
||||
private IArtworkProviderConfigurationRepository? _artworkProviderConfigurationRepository;
|
||||
private IPluginRepository? _pluginRepository;
|
||||
private IThemeRepository? _themeRepository;
|
||||
private IUserRepository? _userRepository;
|
||||
@@ -176,6 +177,18 @@ public class UnitOfWork : IUnitOfWork, IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the library artwork provider configuration repository.
|
||||
/// </summary>
|
||||
public IArtworkProviderConfigurationRepository ArtworkProviderConfigurationRepository
|
||||
{
|
||||
get
|
||||
{
|
||||
_artworkProviderConfigurationRepository ??= new ArtworkProviderConfigurationRepository(_luminaDbContext);
|
||||
return _artworkProviderConfigurationRepository;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin repository.
|
||||
/// </summary>
|
||||
@@ -242,6 +255,14 @@ public class UnitOfWork : IUnitOfWork, IDisposable
|
||||
await _luminaDbContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Detaches all the entities tracked by the unit of work, freeing the memory they occupy.
|
||||
/// </summary>
|
||||
public void ClearTrackedEntities()
|
||||
{
|
||||
_luminaDbContext.ChangeTracker.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Begins a new database transaction.
|
||||
/// </summary>
|
||||
|
||||
+30
-13
@@ -1,6 +1,5 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Common.Errors;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Strategies.Environment;
|
||||
using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.ValueObjects;
|
||||
#endregion
|
||||
@@ -38,23 +37,41 @@ internal class FileSystemStructureSeedService : IFileSystemStructureSeedService
|
||||
if (rootPathIdResult.IsFailure)
|
||||
return rootPathIdResult.Errors;
|
||||
|
||||
// create the libraries directory
|
||||
Result<string> librariesPathResult = _pathService.CombinePath(rootPath, "libraries");
|
||||
if (librariesPathResult.IsFailure)
|
||||
return librariesPathResult.Errors;
|
||||
Result<Created> createLibrariesDirectoryResult = EnsureDirectory(rootPathIdResult.Value, "libraries");
|
||||
if (createLibrariesDirectoryResult.IsFailure)
|
||||
return createLibrariesDirectoryResult.Errors;
|
||||
|
||||
Result<FileSystemPathId> libraryPathIdResult = FileSystemPathId.Create(librariesPathResult.Value);
|
||||
if (libraryPathIdResult.IsFailure)
|
||||
return libraryPathIdResult.Errors;
|
||||
Result<Created> createBooksDirectoryResult = EnsureDirectory(rootPathIdResult.Value, "books");
|
||||
if (createBooksDirectoryResult.IsFailure)
|
||||
return createBooksDirectoryResult.Errors;
|
||||
|
||||
Result<bool> librariesDirectoryExistsResult = _environmentContext.DirectoryProviderService.DirectoryExists(libraryPathIdResult.Value);
|
||||
if (librariesDirectoryExistsResult.IsFailure)
|
||||
return librariesDirectoryExistsResult.Errors;
|
||||
return Result.Created;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the directory with the provided <paramref name="directoryName"/> under the <paramref name="rootPathId"/>, when it does not already exist.
|
||||
/// </summary>
|
||||
/// <param name="rootPathId">The id of the root path under which the directory is created.</param>
|
||||
/// <param name="directoryName">The name of the directory to create.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
private Result<Created> EnsureDirectory(FileSystemPathId rootPathId, string directoryName)
|
||||
{
|
||||
Result<string> directoryPathResult = _pathService.CombinePath(rootPathId.Path, directoryName);
|
||||
if (directoryPathResult.IsFailure)
|
||||
return directoryPathResult.Errors;
|
||||
|
||||
Result<FileSystemPathId> directoryPathIdResult = FileSystemPathId.Create(directoryPathResult.Value);
|
||||
if (directoryPathIdResult.IsFailure)
|
||||
return directoryPathIdResult.Errors;
|
||||
|
||||
Result<bool> directoryExistsResult = _environmentContext.DirectoryProviderService.DirectoryExists(directoryPathIdResult.Value);
|
||||
if (directoryExistsResult.IsFailure)
|
||||
return directoryExistsResult.Errors;
|
||||
|
||||
// only create it if it doesn't already exist
|
||||
if (!librariesDirectoryExistsResult.Value)
|
||||
if (!directoryExistsResult.Value)
|
||||
{
|
||||
Result<FileSystemPathId> createDirectoryResult = _environmentContext.DirectoryProviderService.CreateDirectory(rootPathIdResult.Value, "libraries");
|
||||
Result<FileSystemPathId> createDirectoryResult = _environmentContext.DirectoryProviderService.CreateDirectory(rootPathId, directoryName);
|
||||
if (createDirectoryResult.IsFailure)
|
||||
return createDirectoryResult.Errors;
|
||||
}
|
||||
|
||||
+10
-10
@@ -63,7 +63,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// <summary>
|
||||
/// Gets whether this media library should update the metadata of its elements from the web, or not.
|
||||
/// </summary>
|
||||
public bool DownloadMetadataFromWeb { get; private set; } = true;
|
||||
public bool CanDownloadMetadataFromWeb { get; private set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether this media library should copy the downloaded metadata into the media library content locations, or not.
|
||||
@@ -97,7 +97,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// <param name="coverImage">The path of the image file used as the cover for the library.</param>
|
||||
/// <param name="isEnabled">Whether this media library is enabled or not. A disabled media library is never shown or changed.</param>
|
||||
/// <param name="isLocked">Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
/// <param name="scanIds">The list of objects representing the unique identifier of scans of the media library.</param>
|
||||
@@ -110,7 +110,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
string? coverImage,
|
||||
bool isEnabled,
|
||||
bool isLocked,
|
||||
bool downloadMetadataFromWeb,
|
||||
bool canDownloadMetadataFromWeb,
|
||||
bool shouldSaveMetadataInMediaDirectories,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan,
|
||||
List<ScanId> scanIds) : base(id)
|
||||
@@ -122,7 +122,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
CoverImage = coverImage;
|
||||
IsEnabled = isEnabled;
|
||||
IsLocked = isLocked;
|
||||
DownloadMetadataFromWeb = downloadMetadataFromWeb;
|
||||
CanDownloadMetadataFromWeb = canDownloadMetadataFromWeb;
|
||||
ShouldSaveMetadataInMediaDirectories = shouldSaveMetadataInMediaDirectories;
|
||||
ShouldSkipUnchangedDirectoriesDuringScan = shouldSkipUnchangedDirectoriesDuringScan;
|
||||
_scanIds = scanIds;
|
||||
@@ -138,7 +138,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// <param name="coverImageSourcePath">The path of the image file chosen by the user to be used as the cover for the library.</param>
|
||||
/// <param name="isEnabled">Whether this media library is enabled or not. A disabled media library is never shown or changed.</param>
|
||||
/// <param name="isLocked">Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
/// <param name="scanIds">The list of objects representing the unique identifier of scans of the media library.</param>
|
||||
@@ -153,7 +153,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
string? coverImageSourcePath,
|
||||
bool isEnabled,
|
||||
bool isLocked,
|
||||
bool downloadMetadataFromWeb,
|
||||
bool canDownloadMetadataFromWeb,
|
||||
bool shouldSaveMetadataInMediaDirectories,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan,
|
||||
List<ScanId> scanIds)
|
||||
@@ -176,7 +176,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
coverImageSourcePath,
|
||||
isEnabled,
|
||||
isLocked,
|
||||
downloadMetadataFromWeb,
|
||||
canDownloadMetadataFromWeb,
|
||||
shouldSaveMetadataInMediaDirectories,
|
||||
shouldSkipUnchangedDirectoriesDuringScan,
|
||||
scanIds
|
||||
@@ -194,7 +194,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
/// <param name="coverImageSourcePath">The path of the image file chosen by the user to be used as the cover for the library.</param>
|
||||
/// <param name="isEnabled">Whether this media library is enabled or not. A disabled media library is never shown or changed.</param>
|
||||
/// <param name="isLocked">Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether this media library should update the metadata of its elements from the web, or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether this media library should copy the downloaded metadata into the media library content locations, or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.</param>
|
||||
/// <param name="scanIds">The list of objects representing the unique identifier of scans of the media library.</param>
|
||||
@@ -210,7 +210,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
string? coverImageSourcePath,
|
||||
bool isEnabled,
|
||||
bool isLocked,
|
||||
bool downloadMetadataFromWeb,
|
||||
bool canDownloadMetadataFromWeb,
|
||||
bool shouldSaveMetadataInMediaDirectories,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan,
|
||||
List<ScanId> scanIds)
|
||||
@@ -233,7 +233,7 @@ public class Library : AggregateRoot<LibraryId>
|
||||
coverImageSourcePath,
|
||||
isEnabled,
|
||||
isLocked,
|
||||
downloadMetadataFromWeb,
|
||||
canDownloadMetadataFromWeb,
|
||||
shouldSaveMetadataInMediaDirectories,
|
||||
shouldSkipUnchangedDirectoriesDuringScan,
|
||||
scanIds
|
||||
|
||||
+1
-2
@@ -17,10 +17,9 @@ public interface IMediaLibraryScanningService
|
||||
/// </summary>
|
||||
/// <param name="scan">The media library scan to start.</param>
|
||||
/// <param name="libraryType">The type of the media library to be scanned.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether the library permits downloading data from the web, or not.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
Task<Result<Success>> StartScanAsync(LibraryScan scan, LibraryType libraryType, bool downloadMetadataFromWeb, CancellationToken cancellationToken);
|
||||
Task<Result<Success>> StartScanAsync(LibraryScan scan, LibraryType libraryType, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Cancels <paramref name="scan"/>.
|
||||
|
||||
+4
-5
@@ -1,7 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using Lumina.Domain.Common.Events;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Cancellation;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Jobs;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Progress;
|
||||
@@ -9,6 +8,7 @@ using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.Library
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
@@ -55,10 +55,9 @@ internal class MediaLibraryScanningService : IMediaLibraryScanningService
|
||||
/// </summary>
|
||||
/// <param name="scan">The media library scan to start.</param>
|
||||
/// <param name="libraryType">The type of the media library to be scanned.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether the library permits downloading data from the web, or not.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
|
||||
public async Task<Result<Success>> StartScanAsync(LibraryScan scan, LibraryType libraryType, bool downloadMetadataFromWeb, CancellationToken cancellationToken)
|
||||
public async Task<Result<Success>> StartScanAsync(LibraryScan scan, LibraryType libraryType, CancellationToken cancellationToken)
|
||||
{
|
||||
// mark the scan itself as started
|
||||
Result<Success> startScanResult = scan.StartScan();
|
||||
@@ -81,7 +80,7 @@ internal class MediaLibraryScanningService : IMediaLibraryScanningService
|
||||
IMediaTypeScanner scanner = _mediaLibraryScannerFactory.CreateLibraryScanner(libraryType);
|
||||
// get the list of scan jobs for the retrieved scanner. It is impotant to enumerate them here, because deferred execuction would destroy any graph relationships
|
||||
// and properties we might set before putting the jobs on the in-memory queue.
|
||||
List<IMediaLibraryScanJob> jobs = [.. scanner.CreateScanJobsForLibrary(scan.LibraryId, downloadMetadataFromWeb)];
|
||||
List<IMediaLibraryScanJob> jobs = [.. scanner.CreateScanJobsForLibrary(scan.LibraryId)];
|
||||
|
||||
// count total jobs in the chain by traversing the job graph
|
||||
int totalJobs = CountTotalJobs(jobs);
|
||||
|
||||
+1
-2
@@ -21,7 +21,6 @@ public interface IMediaTypeScanner
|
||||
/// Creates the media library scan jobs for the provided media library.
|
||||
/// </summary>
|
||||
/// <param name="libraryId">The unique identifier of the media library for which to create the media library scan jobs.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether the library permits downloading data from the web, or not.</param>
|
||||
/// <returns>A collection of media library scan jobs.</returns>
|
||||
IEnumerable<IMediaLibraryScanJob> CreateScanJobsForLibrary(LibraryId libraryId, bool downloadMetadataFromWeb);
|
||||
IEnumerable<IMediaLibraryScanJob> CreateScanJobsForLibrary(LibraryId libraryId);
|
||||
}
|
||||
+37
-21
@@ -4,7 +4,6 @@ using Lumina.Domain.Common.Models.Core;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserAggregate.ValueObjects;
|
||||
using Lumina.Domain.Core.BoundedContexts.UserManagementBoundedContext.UserSettingsAggregate.ValueObjects;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
@@ -20,6 +19,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
private const int DEFAULT_ITEMS_PER_PAGE = 48;
|
||||
private const bool DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER = false;
|
||||
private const bool DEFAULT_IS_THEME_CACHING_ENABLED = true;
|
||||
private const bool DEFAULT_AGGREGATE_METADATA_WHEN_MISSING = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the object representing the unique identifier of the user that owns these settings.
|
||||
@@ -39,13 +39,18 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// <summary>
|
||||
/// Gets whether the "The" prefix of library item titles is ignored by the alpha picker, or not.
|
||||
/// </summary>
|
||||
public bool IgnoreThePrefixForAlphaPicker { get; private set; }
|
||||
public bool ShouldIgnoreThePrefixForAlphaPicker { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the theme data served to this user is cached, or not.
|
||||
/// </summary>
|
||||
public bool IsThemeCachingEnabled { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.
|
||||
/// </summary>
|
||||
public bool ShouldAggregateMetadataWhenMissing { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UserSettings"/> class.
|
||||
/// </summary>
|
||||
@@ -53,21 +58,24 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// <param name="userId">The object representing the unique identifier of the user that owns these settings.</param>
|
||||
/// <param name="isPaginationEnabled">Whether pagination is enabled for the user, or not.</param>
|
||||
/// <param name="itemsPerPage">The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||
private UserSettings(
|
||||
UserSettingsId id,
|
||||
UserId userId,
|
||||
bool isPaginationEnabled,
|
||||
int itemsPerPage,
|
||||
bool ignoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled) : base(id)
|
||||
bool shouldIgnoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled,
|
||||
bool shouldAggregateMetadataWhenMissing) : base(id)
|
||||
{
|
||||
UserId = userId;
|
||||
IsPaginationEnabled = isPaginationEnabled;
|
||||
ItemsPerPage = itemsPerPage;
|
||||
IgnoreThePrefixForAlphaPicker = ignoreThePrefixForAlphaPicker;
|
||||
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker;
|
||||
IsThemeCachingEnabled = isThemeCachingEnabled;
|
||||
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -78,7 +86,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// </returns>
|
||||
public static Result<UserSettings> Create()
|
||||
{
|
||||
return Create(UserId.CreateUnique(), DEFAULT_IS_PAGINATION_ENABLED, DEFAULT_ITEMS_PER_PAGE, DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER, DEFAULT_IS_THEME_CACHING_ENABLED);
|
||||
return Create(UserId.CreateUnique(), DEFAULT_IS_PAGINATION_ENABLED, DEFAULT_ITEMS_PER_PAGE, DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER, DEFAULT_IS_THEME_CACHING_ENABLED, DEFAULT_AGGREGATE_METADATA_WHEN_MISSING);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -90,7 +98,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// </returns>
|
||||
public static Result<UserSettings> Create(UserId userId)
|
||||
{
|
||||
return Create(userId, DEFAULT_IS_PAGINATION_ENABLED, DEFAULT_ITEMS_PER_PAGE, DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER, DEFAULT_IS_THEME_CACHING_ENABLED);
|
||||
return Create(userId, DEFAULT_IS_PAGINATION_ENABLED, DEFAULT_ITEMS_PER_PAGE, DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER, DEFAULT_IS_THEME_CACHING_ENABLED, DEFAULT_AGGREGATE_METADATA_WHEN_MISSING);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -99,8 +107,9 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// <param name="userId">The object representing the unique identifier of the user that owns these settings.</param>
|
||||
/// <param name="isPaginationEnabled">Whether pagination is enabled for the user, or not.</param>
|
||||
/// <param name="itemsPerPage">The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="UserSettings"/>, or an error message.
|
||||
/// </returns>
|
||||
@@ -108,8 +117,9 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
UserId userId,
|
||||
bool isPaginationEnabled,
|
||||
int itemsPerPage,
|
||||
bool ignoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled)
|
||||
bool shouldIgnoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled,
|
||||
bool shouldAggregateMetadataWhenMissing)
|
||||
{
|
||||
if (itemsPerPage <= 0)
|
||||
return Errors.UserSettings.ItemsPerPageMustBeGreaterThanZero;
|
||||
@@ -119,8 +129,9 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
userId,
|
||||
isPaginationEnabled,
|
||||
itemsPerPage,
|
||||
ignoreThePrefixForAlphaPicker,
|
||||
isThemeCachingEnabled);
|
||||
shouldIgnoreThePrefixForAlphaPicker,
|
||||
isThemeCachingEnabled,
|
||||
shouldAggregateMetadataWhenMissing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -130,8 +141,9 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// <param name="userId">The object representing the unique identifier of the user that owns these settings.</param>
|
||||
/// <param name="isPaginationEnabled">Whether pagination is enabled for the user, or not.</param>
|
||||
/// <param name="itemsPerPage">The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="Result{TValue}"/> containing either a successfully created <see cref="UserSettings"/>, or an error message.
|
||||
/// </returns>
|
||||
@@ -140,13 +152,14 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
UserId userId,
|
||||
bool isPaginationEnabled,
|
||||
int itemsPerPage,
|
||||
bool ignoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled)
|
||||
bool shouldIgnoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled,
|
||||
bool shouldAggregateMetadataWhenMissing)
|
||||
{
|
||||
if (itemsPerPage <= 0)
|
||||
return Errors.UserSettings.ItemsPerPageMustBeGreaterThanZero;
|
||||
|
||||
return new UserSettings(id, userId, isPaginationEnabled, itemsPerPage, ignoreThePrefixForAlphaPicker, isThemeCachingEnabled);
|
||||
return new UserSettings(id, userId, isPaginationEnabled, itemsPerPage, shouldIgnoreThePrefixForAlphaPicker, isThemeCachingEnabled, shouldAggregateMetadataWhenMissing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -154,22 +167,25 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// </summary>
|
||||
/// <param name="isPaginationEnabled">Whether pagination is enabled for the user, or not.</param>
|
||||
/// <param name="itemsPerPage">The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
|
||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful update, or an error.</returns>
|
||||
public Result<Updated> UpdateSettings(
|
||||
bool isPaginationEnabled,
|
||||
int itemsPerPage,
|
||||
bool ignoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled)
|
||||
bool shouldIgnoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled,
|
||||
bool shouldAggregateMetadataWhenMissing)
|
||||
{
|
||||
if (itemsPerPage <= 0)
|
||||
return Errors.UserSettings.ItemsPerPageMustBeGreaterThanZero;
|
||||
|
||||
IsPaginationEnabled = isPaginationEnabled;
|
||||
ItemsPerPage = itemsPerPage;
|
||||
IgnoreThePrefixForAlphaPicker = ignoreThePrefixForAlphaPicker;
|
||||
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker;
|
||||
IsThemeCachingEnabled = isThemeCachingEnabled;
|
||||
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing;
|
||||
return Result.Updated;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ public static partial class Errors
|
||||
public static Error DatabaseConnectionStringCannotBeEmpty => Error.Validation(description: nameof(DatabaseConnectionStringCannotBeEmpty));
|
||||
public static Error MediaRootDirectoryCannotBeEmpty => Error.Validation(description: nameof(MediaRootDirectoryCannotBeEmpty));
|
||||
public static Error MediaLibrariesDirectoryCannotBeEmpty => Error.Validation(description: nameof(MediaLibrariesDirectoryCannotBeEmpty));
|
||||
public static Error MediaBooksDirectoryCannotBeEmpty => Error.Validation(description: nameof(MediaBooksDirectoryCannotBeEmpty));
|
||||
public static Error EncryptionSecretKeyCannotBeEmpty => Error.Validation(description: nameof(EncryptionSecretKeyCannotBeEmpty));
|
||||
public static Error EncryptionSecretKeyMustBeABase64String => Error.Validation(description: nameof(EncryptionSecretKeyMustBeABase64String));
|
||||
public static Error JwtSecretKeyCannotBeEmpty => Error.Validation(description: nameof(JwtSecretKeyCannotBeEmpty));
|
||||
|
||||
@@ -23,5 +23,9 @@ public class MediaSettingsDtoValidator : AbstractValidator<MediaSettingsDto>
|
||||
RuleFor(settings => settings.LibrariesDirectory)
|
||||
.NotEmpty()
|
||||
.WithError(Errors.Errors.Configuration.MediaLibrariesDirectoryCannotBeEmpty);
|
||||
|
||||
RuleFor(settings => settings.BooksDirectory)
|
||||
.NotEmpty()
|
||||
.WithError(Errors.Errors.Configuration.MediaBooksDirectoryCannotBeEmpty);
|
||||
}
|
||||
}
|
||||
+267
-68
@@ -1,9 +1,12 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Application.Common.DataAccess.Entities.Plugins;
|
||||
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Books;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Application.Core.MediaLibrary.WrittenContentLibrary.BooksLibrary.Artwork;
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using Lumina.Domain.Common.Events;
|
||||
@@ -77,71 +80,140 @@ internal sealed class MediaLibraryScanMetadataEnrichmentJob : MediaLibraryScanJo
|
||||
|
||||
MediaLibraryScanCompositeId compositeKey = MediaLibraryScanCompositeId.Create(ScanId, UserId);
|
||||
|
||||
// get the metadata providers configured for the media library, in their configured order, that support the media library type
|
||||
// load the media library, whose name is used to build the directory of the book artwork, and whose setting determines
|
||||
// whether the providers that require access to the web are used during the enrichment
|
||||
string libraryName = string.Empty;
|
||||
bool canDownloadMetadataFromWeb = false;
|
||||
if (unitOfWork.LibraryRepository is not null)
|
||||
{
|
||||
Result<LibraryEntity?> getLibraryResult = await unitOfWork.LibraryRepository.GetByIdAsync(LibraryId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getLibraryResult.IsFailure || getLibraryResult.Value is null)
|
||||
_logger.LogWarning("Failed to read the media library, the book artwork will not be stored and the providers requiring the web will not be used.");
|
||||
else
|
||||
{
|
||||
libraryName = getLibraryResult.Value.Title;
|
||||
canDownloadMetadataFromWeb = getLibraryResult.Value.CanDownloadMetadataFromWeb;
|
||||
}
|
||||
}
|
||||
|
||||
// get the metadata providers configured for the media library, in their configured order, that support the media library type,
|
||||
// skipping the providers that require access to the web when the media library does not permit downloading data from the web
|
||||
Result<IReadOnlyList<LibraryMetadataProviderConfigurationEntity>> getConfigurationsResult = await unitOfWork.LibraryMetadataProviderConfigurationRepository.GetByLibraryIdAsync(LibraryId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getConfigurationsResult.IsFailure)
|
||||
throw new InvalidOperationException(getConfigurationsResult.FirstError.Description);
|
||||
List<IRemoteMetadataProvider> providers = [];
|
||||
List<IMetadataProvider> providers = [];
|
||||
foreach (LibraryMetadataProviderConfigurationEntity configuration in getConfigurationsResult.Value.Where(configuration => configuration.IsEnabled).OrderBy(configuration => configuration.Rank))
|
||||
{
|
||||
List<IRemoteMetadataProvider> configuredProviders = [.. asyncServiceScope.ServiceProvider
|
||||
.GetKeyedServices<IRemoteMetadataProvider>(configuration.PluginId)
|
||||
.Where(provider => provider.SupportedLibraryType == LibraryType.Book)];
|
||||
List<IMetadataProvider> configuredProviders = [.. asyncServiceScope.ServiceProvider
|
||||
.GetKeyedServices<IMetadataProvider>(configuration.PluginId)
|
||||
.Where(provider => provider.SupportedLibraryTypes.Contains(LibraryType.Book)
|
||||
&& (canDownloadMetadataFromWeb || !provider.RequiresWebAccess))];
|
||||
if (configuredProviders.Count == 0)
|
||||
_logger.LogWarning("No metadata provider was found for the configured plugin with Id '{PluginId}' and the {LibraryType} library type.", configuration.PluginId, LibraryType.Book);
|
||||
providers.AddRange(configuredProviders);
|
||||
}
|
||||
|
||||
// read whether the metadata of the books of the user is aggregated from multiple providers, when fields are missing
|
||||
bool shouldAggregateMetadataWhenMissing = false;
|
||||
if (unitOfWork.UserSettingsRepository is not null)
|
||||
{
|
||||
Result<UserSettingsEntity?> getUserSettingsResult = await unitOfWork.UserSettingsRepository.GetByUserIdAsync(UserId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getUserSettingsResult.IsFailure)
|
||||
_logger.LogWarning("Failed to read the user settings, the metadata will not be aggregated across providers.");
|
||||
else
|
||||
shouldAggregateMetadataWhenMissing = getUserSettingsResult.Value?.ShouldAggregateMetadataWhenMissing ?? false;
|
||||
}
|
||||
|
||||
// get the artwork providers configured for the media library, in their configured order, that support the media library type.
|
||||
// the artwork resolution is best-effort, so a failure to read the artwork configurations must not prevent the metadata enrichment from proceeding
|
||||
List<IArtworkProvider> artworkProviders = [];
|
||||
if (unitOfWork.ArtworkProviderConfigurationRepository is not null)
|
||||
{
|
||||
Result<IReadOnlyList<LibraryArtworkProviderConfigurationEntity>> getArtworkConfigurationsResult = await unitOfWork.ArtworkProviderConfigurationRepository.GetByLibraryIdAsync(LibraryId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getArtworkConfigurationsResult.IsFailure)
|
||||
_logger.LogWarning("Failed to read the artwork provider configurations.");
|
||||
else
|
||||
{
|
||||
foreach (LibraryArtworkProviderConfigurationEntity configuration in getArtworkConfigurationsResult.Value.Where(configuration => configuration.IsEnabled).OrderBy(configuration => configuration.Rank))
|
||||
{
|
||||
List<IArtworkProvider> configuredProviders = [.. asyncServiceScope.ServiceProvider
|
||||
.GetKeyedServices<IArtworkProvider>(configuration.PluginId)
|
||||
.Where(provider => provider.SupportedLibraryTypes.Contains(LibraryType.Book)
|
||||
&& (canDownloadMetadataFromWeb || !provider.RequiresWebAccess))];
|
||||
if (configuredProviders.Count == 0)
|
||||
_logger.LogWarning("No artwork provider was found for the configured plugin with Id '{PluginId}' and the {LibraryType} library type.", configuration.PluginId, LibraryType.Book);
|
||||
artworkProviders.AddRange(configuredProviders);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IBookArtworkService? bookArtworkService = asyncServiceScope.ServiceProvider.GetService<IBookArtworkService>();
|
||||
|
||||
// count the books that need their metadata enriched, for progress reporting purposes
|
||||
Result<int> getBooksToEnrichCountResult = await unitOfWork.BookRepository.GetBooksNeedingMetadataCountAsync(LibraryId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getBooksToEnrichCountResult.IsFailure)
|
||||
throw new InvalidOperationException(getBooksToEnrichCountResult.FirstError.Description);
|
||||
int totalBooksToEnrich = getBooksToEnrichCountResult.Value;
|
||||
|
||||
// set the initial progress of the scan job
|
||||
Result<Success> publishJobProgressResult = await PublishJobProgressAsync(domainEventPublisher, compositeKey, 0, totalBooksToEnrich, cancellationToken).ConfigureAwait(false);
|
||||
if (publishJobProgressResult.IsFailure)
|
||||
throw new InvalidOperationException(publishJobProgressResult.FirstError.Description);
|
||||
|
||||
DateTime lastUpdateTime = DateTime.UtcNow;
|
||||
int minUpdateIntervalMs = 100;
|
||||
int processedBooksCount = 0;
|
||||
string? lastPath = null;
|
||||
|
||||
// process the books that need their metadata enriched in pages, keeping the peak memory bounded regardless of the library size
|
||||
while (true)
|
||||
// when no metadata provider is available, the books must not be marked as failed to enrich, so the enrichment is skipped entirely
|
||||
if (providers.Count > 0)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
Result<int> getBooksToEnrichCountResult = await unitOfWork.BookRepository.GetBooksNeedingMetadataCountAsync(LibraryId.Value, cancellationToken).ConfigureAwait(false);
|
||||
if (getBooksToEnrichCountResult.IsFailure)
|
||||
throw new InvalidOperationException(getBooksToEnrichCountResult.FirstError.Description);
|
||||
int totalBooksToEnrich = getBooksToEnrichCountResult.Value;
|
||||
|
||||
Result<IReadOnlyList<BookEntity>> getBooksPageResult = await unitOfWork.BookRepository.GetBooksNeedingMetadataAsync(LibraryId.Value, lastPath, ENRICHMENT_PAGE_SIZE, cancellationToken).ConfigureAwait(false);
|
||||
if (getBooksPageResult.IsFailure)
|
||||
throw new InvalidOperationException(getBooksPageResult.FirstError.Description);
|
||||
IReadOnlyList<BookEntity> booksPage = getBooksPageResult.Value;
|
||||
if (booksPage.Count == 0)
|
||||
break;
|
||||
// set the initial progress of the scan job
|
||||
Result<Success> publishJobProgressResult = await PublishJobProgressAsync(domainEventPublisher, compositeKey, 0, totalBooksToEnrich, cancellationToken).ConfigureAwait(false);
|
||||
if (publishJobProgressResult.IsFailure)
|
||||
throw new InvalidOperationException(publishJobProgressResult.FirstError.Description);
|
||||
|
||||
foreach (BookEntity bookEntity in booksPage)
|
||||
DateTime lastUpdateTime = DateTime.UtcNow;
|
||||
int minUpdateIntervalMs = 100;
|
||||
int processedBooksCount = 0;
|
||||
|
||||
// process the books that need their metadata enriched in pages, keeping the peak memory bounded regardless of the library size
|
||||
while (true)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
await EnrichBookAsync(bookEntity, providers, unitOfWork.BookRepository, cancellationToken).ConfigureAwait(false);
|
||||
Result<IReadOnlyList<BookEntity>> getBooksPageResult = await unitOfWork.BookRepository.GetBooksNeedingMetadataAsync(LibraryId.Value, lastPath, ENRICHMENT_PAGE_SIZE, cancellationToken).ConfigureAwait(false);
|
||||
if (getBooksPageResult.IsFailure)
|
||||
throw new InvalidOperationException(getBooksPageResult.FirstError.Description);
|
||||
IReadOnlyList<BookEntity> booksPage = getBooksPageResult.Value;
|
||||
if (booksPage.Count == 0)
|
||||
break;
|
||||
|
||||
// check if enough time has passed since last update
|
||||
DateTime now = DateTime.UtcNow;
|
||||
if ((now - lastUpdateTime).TotalMilliseconds >= minUpdateIntervalMs)
|
||||
foreach (BookEntity bookEntity in booksPage)
|
||||
{
|
||||
// increment the number of processed elements progress
|
||||
publishJobProgressResult = await PublishJobProgressAsync(domainEventPublisher, compositeKey, Interlocked.Increment(ref processedBooksCount), totalBooksToEnrich, cancellationToken).ConfigureAwait(false);
|
||||
if (publishJobProgressResult.IsFailure)
|
||||
throw new InvalidOperationException(publishJobProgressResult.FirstError.Description);
|
||||
lastUpdateTime = now;
|
||||
}
|
||||
}
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
lastPath = booksPage[^1].Path;
|
||||
await EnrichBookAsync(bookEntity, providers, shouldAggregateMetadataWhenMissing, artworkProviders, bookArtworkService, libraryName, unitOfWork.BookRepository, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// check if enough time has passed since last update
|
||||
DateTime now = DateTime.UtcNow;
|
||||
if ((now - lastUpdateTime).TotalMilliseconds >= minUpdateIntervalMs)
|
||||
{
|
||||
// increment the number of processed elements progress
|
||||
publishJobProgressResult = await PublishJobProgressAsync(domainEventPublisher, compositeKey, Interlocked.Increment(ref processedBooksCount), totalBooksToEnrich, cancellationToken).ConfigureAwait(false);
|
||||
if (publishJobProgressResult.IsFailure)
|
||||
throw new InvalidOperationException(publishJobProgressResult.FirstError.Description);
|
||||
lastUpdateTime = now;
|
||||
}
|
||||
}
|
||||
|
||||
// persist the enriched books of this page, then detach them from the change tracker, keeping the peak memory bounded regardless of the library size
|
||||
await unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
|
||||
unitOfWork.ClearTrackedEntities();
|
||||
|
||||
lastPath = booksPage[^1].Path;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogWarning("No metadata provider is configured for the media library with Id '{LibraryId}', the metadata enrichment will be skipped.", LibraryId.Value);
|
||||
}
|
||||
|
||||
await unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
|
||||
// persist the changes when no page was processed, so that the scan still saves even when there are no books to enrich
|
||||
if (lastPath is null)
|
||||
await unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// this job finished, and it's the last in the chain, the scan is completed
|
||||
Status = LibraryScanJobStatus.Completed;
|
||||
@@ -166,21 +238,29 @@ internal sealed class MediaLibraryScanMetadataEnrichmentJob : MediaLibraryScanJo
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enriches the metadata of the provided <paramref name="bookEntity"/>, using the provided <paramref name="providers"/> in their configured order.
|
||||
/// Enriches the metadata and the artwork of the provided <paramref name="bookEntity"/>, using the provided metadata and artwork providers in their configured order.
|
||||
/// </summary>
|
||||
/// <param name="bookEntity">The book whose metadata is enriched.</param>
|
||||
/// <param name="providers">The metadata providers, in their configured order.</param>
|
||||
/// <param name="bookRepository">The repository used to persist the enriched metadata.</param>
|
||||
/// <param name="bookEntity">The book whose metadata and artwork are enriched.</param>
|
||||
/// <param name="metadataProviders">The metadata providers, in their configured order.</param>
|
||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the book is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||
/// <param name="artworkProviders">The artwork providers, in their configured order.</param>
|
||||
/// <param name="bookArtworkService">The service used to store the artwork of the book.</param>
|
||||
/// <param name="libraryName">The name of the media library the book belongs to.</param>
|
||||
/// <param name="bookRepository">The repository used to persist the enriched book.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
private static async Task EnrichBookAsync(BookEntity bookEntity, IReadOnlyList<IRemoteMetadataProvider> providers, IBookRepository bookRepository, CancellationToken cancellationToken)
|
||||
private async Task EnrichBookAsync(BookEntity bookEntity, IReadOnlyList<IMetadataProvider> metadataProviders, bool shouldAggregateMetadataWhenMissing, IReadOnlyList<IArtworkProvider> artworkProviders, IBookArtworkService? bookArtworkService, string libraryName, IBookRepository bookRepository, CancellationToken cancellationToken)
|
||||
{
|
||||
// when no metadata provider is available, the book must not be marked as failed to enrich, so the enrichment is skipped
|
||||
if (metadataProviders.Count == 0)
|
||||
return;
|
||||
|
||||
// convert the book to a domain object
|
||||
Result<Book> getBookResult = bookEntity.ToDomainEntity();
|
||||
if (getBookResult.IsFailure)
|
||||
return;
|
||||
Book book = getBookResult.Value;
|
||||
|
||||
BookMetadataLookupDto lookup = new(
|
||||
BookMetadataLookupDto bookMetadataLookup = new(
|
||||
LibraryId: bookEntity.LibraryId,
|
||||
Path: bookEntity.Path,
|
||||
Isbn: bookEntity.ISBNs.Count > 0 ? bookEntity.ISBNs.Where(isbn => isbn.Value is not null).Select(isbn => isbn.Value!).First() : null, // TODO: this should not take just the first ISBN, it should ask the metadata plugin to retry with the next ISBN, if the first one returned no results
|
||||
@@ -190,24 +270,84 @@ internal sealed class MediaLibraryScanMetadataEnrichmentJob : MediaLibraryScanJo
|
||||
LanguageCode: bookEntity.LanguageCode
|
||||
);
|
||||
|
||||
// try the metadata providers in order, until one returns usable metadata
|
||||
foreach (IRemoteMetadataProvider provider in providers)
|
||||
BookMetadataDto? appliedMetadata = shouldAggregateMetadataWhenMissing
|
||||
? await AggregateMetadataAsync(book, bookMetadataLookup, metadataProviders, cancellationToken).ConfigureAwait(false)
|
||||
: await TryFirstProviderMetadataAsync(book, bookMetadataLookup, metadataProviders, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (appliedMetadata is null)
|
||||
{
|
||||
// no metadata provider returned usable metadata, mark the book as failed to enrich
|
||||
book.MarkMetadataAsFailed();
|
||||
Result<Updated> markFailedResult = await bookRepository.UpdateAsync(book.ToRepositoryEntity(), cancellationToken).ConfigureAwait(false);
|
||||
if (markFailedResult.IsFailure)
|
||||
_logger.LogWarning("Failed to persist the failed enrichment state of the book with Id '{BookId}' at path '{BookPath}'.", book.Id.Value, book.Path);
|
||||
return;
|
||||
}
|
||||
|
||||
// resolve the artwork of the book from the artwork providers, in their configured order
|
||||
await EnrichBookArtworkAsync(book, appliedMetadata, artworkProviders, bookArtworkService, libraryName, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
Result<Updated> updateBookResult = await bookRepository.UpdateAsync(book.ToRepositoryEntity(), cancellationToken).ConfigureAwait(false);
|
||||
if (updateBookResult.IsFailure)
|
||||
_logger.LogWarning("Failed to persist the enriched book with Id '{BookId}' at path '{BookPath}'.", book.Id.Value, book.Path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries the <paramref name="metadataProviders"/> in order, applying the metadata of the first one that returns usable metadata.
|
||||
/// </summary>
|
||||
/// <param name="book">The book onto which the metadata is applied.</param>
|
||||
/// <param name="bookMetadataLookup">The lookup describing the book.</param>
|
||||
/// <param name="metadataProviders">The metadata providers, in their configured order.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The applied metadata, or <see langword="null"/> when no provider returned usable metadata.</returns>
|
||||
private static async Task<BookMetadataDto?> TryFirstProviderMetadataAsync(Book book, BookMetadataLookupDto bookMetadataLookup, IReadOnlyList<IMetadataProvider> metadataProviders, CancellationToken cancellationToken)
|
||||
{
|
||||
foreach (IMetadataProvider metadataProvider in metadataProviders)
|
||||
{
|
||||
try
|
||||
{
|
||||
MetadataDto? metadataResult = await provider.GetMetadataAsync(lookup, cancellationToken).ConfigureAwait(false);
|
||||
MetadataDto? metadataResult = await metadataProvider.GetMetadataAsync(bookMetadataLookup, cancellationToken).ConfigureAwait(false);
|
||||
if (metadataResult is not BookMetadataDto bookMetadata || !IsUsableMetadata(bookMetadata))
|
||||
continue;
|
||||
|
||||
Result<Success> applyMetadataResult = book.ApplyMetadata(bookMetadata, provider.Name, DateTime.UtcNow);
|
||||
Result<Success> applyMetadataResult = book.ApplyMetadata(bookMetadata, metadataProvider.Name, DateTime.UtcNow);
|
||||
if (applyMetadataResult.IsFailure)
|
||||
continue;
|
||||
return bookMetadata;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// a failing metadata provider must not prevent the other providers from being tried
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Result<Updated> updateBookResult = await bookRepository.UpdateAsync(book.ToRepositoryEntity(), cancellationToken).ConfigureAwait(false);
|
||||
if (updateBookResult.IsFailure)
|
||||
/// <summary>
|
||||
/// Aggregates the metadata of the <paramref name="book"/> from all the <paramref name="metadataProviders"/>, in their configured order, filling the fields that the earlier providers lack with the values of the later ones.
|
||||
/// </summary>
|
||||
/// <param name="book">The book onto which the aggregated metadata is applied.</param>
|
||||
/// <param name="bookMetadataLookup">The lookup describing the book.</param>
|
||||
/// <param name="metadataProviders">The metadata providers, in their configured order.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>The applied aggregated metadata, or <see langword="null"/> when no provider returned usable metadata.</returns>
|
||||
private static async Task<BookMetadataDto?> AggregateMetadataAsync(Book book, BookMetadataLookupDto bookMetadataLookup, IReadOnlyList<IMetadataProvider> metadataProviders, CancellationToken cancellationToken)
|
||||
{
|
||||
BookMetadataDto? mergedMetadata = null;
|
||||
List<string> contributingProviders = [];
|
||||
|
||||
foreach (IMetadataProvider metadataProvider in metadataProviders)
|
||||
{
|
||||
try
|
||||
{
|
||||
MetadataDto? metadataResult = await metadataProvider.GetMetadataAsync(bookMetadataLookup, cancellationToken).ConfigureAwait(false);
|
||||
if (metadataResult is not BookMetadataDto bookMetadata || !IsUsableMetadata(bookMetadata))
|
||||
continue;
|
||||
|
||||
return;
|
||||
mergedMetadata = mergedMetadata is null ? bookMetadata : MetadataAggregator.Merge(mergedMetadata, bookMetadata);
|
||||
contributingProviders.Add(metadataProvider.Name);
|
||||
// the identifiers and the title discovered by the earlier providers are fed to the later ones, so that they can look up the book precisely
|
||||
bookMetadataLookup = EnrichLookup(bookMetadataLookup, mergedMetadata);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -215,25 +355,84 @@ internal sealed class MediaLibraryScanMetadataEnrichmentJob : MediaLibraryScanJo
|
||||
}
|
||||
}
|
||||
|
||||
// no metadata provider returned usable metadata, mark the book as failed to enrich
|
||||
book.MarkMetadataAsFailed();
|
||||
await bookRepository.UpdateAsync(book.ToRepositoryEntity(), cancellationToken).ConfigureAwait(false);
|
||||
if (mergedMetadata is null)
|
||||
return null;
|
||||
|
||||
Result<Success> applyMetadataResult = book.ApplyMetadata(mergedMetadata, string.Join(", ", contributingProviders.Distinct(StringComparer.Ordinal)), DateTime.UtcNow);
|
||||
return applyMetadataResult.IsFailure ? null : mergedMetadata;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the provided <paramref name="metadata"/> is usable, meaning it has a title and at least one primary identifier.
|
||||
/// Resolves the artwork of the <paramref name="book"/> from the <paramref name="artworkProviders"/>, in their configured order, storing the artwork of the first provider that returns it.
|
||||
/// </summary>
|
||||
/// <param name="metadata">The metadata to validate.</param>
|
||||
/// <returns><see langword="true"/> when the metadata is usable, otherwise <see langword="false"/>.</returns>
|
||||
private static bool IsUsableMetadata(BookMetadataDto metadata)
|
||||
/// <param name="book">The book whose artwork is enriched.</param>
|
||||
/// <param name="appliedMetadata">The metadata applied to the book, used to build the directory of the book artwork.</param>
|
||||
/// <param name="artworkProviders">The artwork providers, in their configured order.</param>
|
||||
/// <param name="bookArtworkService">The service used to store the artwork of the book.</param>
|
||||
/// <param name="libraryName">The name of the media library the book belongs to.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
private static async Task EnrichBookArtworkAsync(Book book, BookMetadataDto appliedMetadata, IReadOnlyList<IArtworkProvider> artworkProviders, IBookArtworkService? bookArtworkService, string libraryName, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(metadata.Title))
|
||||
return false;
|
||||
return !string.IsNullOrWhiteSpace(metadata.GoodreadsId)
|
||||
|| !string.IsNullOrWhiteSpace(metadata.OpenLibraryId)
|
||||
|| !string.IsNullOrWhiteSpace(metadata.GoogleBooksId)
|
||||
|| !string.IsNullOrWhiteSpace(metadata.ASIN)
|
||||
|| (metadata.Isbns is not null && metadata.Isbns.Count > 0);
|
||||
if (bookArtworkService is null || artworkProviders.Count == 0)
|
||||
return;
|
||||
|
||||
foreach (IArtworkProvider provider in artworkProviders)
|
||||
{
|
||||
ArtworkDto? artwork = null;
|
||||
try
|
||||
{
|
||||
artwork = await provider.GetArtworkAsync(new BookMetadataLookupDto(LibraryId: book.LibraryId.Value, Path: book.Path), cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// a failing artwork provider must not prevent the other providers from being tried
|
||||
}
|
||||
|
||||
if (artwork is null)
|
||||
continue;
|
||||
|
||||
// a provider that returns remote artwork must declare that it requires web access, otherwise downloading it would contradict the provider's contract
|
||||
if (!string.IsNullOrWhiteSpace(artwork.RemoteUrl) && !provider.RequiresWebAccess)
|
||||
continue;
|
||||
|
||||
string authorName = appliedMetadata.Contributors?.FirstOrDefault(contributor => contributor.Name?.DisplayName is not null)?.Name?.DisplayName ?? string.Empty;
|
||||
string bookTitle = appliedMetadata.Title ?? book.Metadata.Title;
|
||||
Result<string> saveArtworkResult = await bookArtworkService.SaveBookArtworkAsync(book.LibraryId.Value, book.Id.Value, libraryName, authorName, bookTitle, artwork, cancellationToken).ConfigureAwait(false);
|
||||
if (saveArtworkResult.IsFailure)
|
||||
continue;
|
||||
|
||||
book.SetBookCoverImagePath(saveArtworkResult.Value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enriches the <paramref name="bookMetadataLookup"/> with the identifiers and the title discovered by the already queried metadata providers.
|
||||
/// </summary>
|
||||
/// <param name="bookMetadataLookup">The lookup to enrich.</param>
|
||||
/// <param name="bookMetadata">The metadata discovered by the already queried metadata providers.</param>
|
||||
/// <returns>The enriched lookup.</returns>
|
||||
private static BookMetadataLookupDto EnrichLookup(BookMetadataLookupDto bookMetadataLookup, BookMetadataDto bookMetadata)
|
||||
{
|
||||
string? isbn = bookMetadataLookup.Isbn ?? bookMetadata.Isbns?.FirstOrDefault()?.Value;
|
||||
string? openLibraryId = bookMetadataLookup.OpenLibraryId ?? bookMetadata.OpenLibraryId;
|
||||
string? title = bookMetadataLookup.Title ?? bookMetadata.Title;
|
||||
return bookMetadataLookup with
|
||||
{
|
||||
Isbn = isbn,
|
||||
OpenLibraryId = openLibraryId,
|
||||
Title = title
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the provided <paramref name="bookMetadata"/> is usable, meaning it has a title.
|
||||
/// </summary>
|
||||
/// <param name="bookMetadata">The metadata to validate.</param>
|
||||
/// <returns><see langword="true"/> when the metadata is usable, otherwise <see langword="false"/>.</returns>
|
||||
private static bool IsUsableMetadata(BookMetadataDto bookMetadata)
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(bookMetadata.Title);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Contracts.DTO.Common;
|
||||
using Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Infrastructure.Core.MediaLibrary.Management.Scanning.Jobs.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Merges the book metadata returned by multiple metadata providers into a single book metadata, giving priority to the first provider that provides a value for each field.
|
||||
/// </summary>
|
||||
internal static class MetadataAggregator
|
||||
{
|
||||
/// <summary>
|
||||
/// Merges <paramref name="first"/> with <paramref name="second"/>, keeping the first non-empty value of each scalar field, and the union of the collection fields.
|
||||
/// </summary>
|
||||
/// <param name="first">The first metadata to merge, whose values have priority.</param>
|
||||
/// <param name="second">The second metadata to merge, filling the fields that the first metadata lacks.</param>
|
||||
/// <returns>The merged metadata.</returns>
|
||||
public static BookMetadataDto Merge(BookMetadataDto first, BookMetadataDto second)
|
||||
{
|
||||
return new BookMetadataDto(
|
||||
FirstOrDefaultReference(first.Title, second.Title),
|
||||
FirstOrDefaultReference(first.OriginalTitle, second.OriginalTitle),
|
||||
FirstOrDefaultReference(first.Description, second.Description),
|
||||
MergeReleaseInfo(first.ReleaseInfo, second.ReleaseInfo),
|
||||
Union(first.Genres, second.Genres, genre => genre.Name),
|
||||
Union(first.Tags, second.Tags, tag => tag.Name),
|
||||
FirstOrDefaultReference(first.Language, second.Language),
|
||||
FirstOrDefaultReference(first.OriginalLanguage, second.OriginalLanguage),
|
||||
FirstOrDefaultReference(first.Publisher, second.Publisher),
|
||||
FirstOrDefaultValue(first.PageCount, second.PageCount),
|
||||
FirstOrDefaultValue(first.Format, second.Format),
|
||||
FirstOrDefaultReference(first.Edition, second.Edition),
|
||||
FirstOrDefaultValue(first.VolumeNumber, second.VolumeNumber),
|
||||
FirstOrDefaultReference(first.Series, second.Series),
|
||||
FirstOrDefaultReference(first.ASIN, second.ASIN),
|
||||
FirstOrDefaultReference(first.GoodreadsId, second.GoodreadsId),
|
||||
FirstOrDefaultReference(first.LCCN, second.LCCN),
|
||||
FirstOrDefaultReference(first.OCLCNumber, second.OCLCNumber),
|
||||
FirstOrDefaultReference(first.OpenLibraryId, second.OpenLibraryId),
|
||||
FirstOrDefaultReference(first.LibraryThingId, second.LibraryThingId),
|
||||
FirstOrDefaultReference(first.GoogleBooksId, second.GoogleBooksId),
|
||||
FirstOrDefaultReference(first.BarnesAndNobleId, second.BarnesAndNobleId),
|
||||
FirstOrDefaultReference(first.AppleBooksId, second.AppleBooksId),
|
||||
Union(first.Isbns, second.Isbns, isbn => isbn.Value),
|
||||
Union(first.Contributors, second.Contributors, contributor => $"{contributor.Name?.DisplayName}|{contributor.Role?.Name}"),
|
||||
Union(first.Ratings, second.Ratings, rating => rating.Source?.ToString()),
|
||||
FirstOrDefaultReference(first.CoverImagePath, second.CoverImagePath));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Merges the release information of the two metadata, keeping the first non-null value of each field.
|
||||
/// </summary>
|
||||
/// <param name="first">The first release information, whose values have priority.</param>
|
||||
/// <param name="second">The second release information, filling the fields that the first one lacks.</param>
|
||||
/// <returns>The merged release information, or <see langword="null"/> when both are <see langword="null"/>.</returns>
|
||||
private static ReleaseInfoDto? MergeReleaseInfo(ReleaseInfoDto? first, ReleaseInfoDto? second)
|
||||
{
|
||||
if (first is null && second is null)
|
||||
return null;
|
||||
|
||||
return new ReleaseInfoDto(
|
||||
FirstOrDefaultValue(first?.OriginalReleaseDate, second?.OriginalReleaseDate),
|
||||
FirstOrDefaultValue(first?.OriginalReleaseYear, second?.OriginalReleaseYear),
|
||||
FirstOrDefaultValue(first?.ReReleaseDate, second?.ReReleaseDate),
|
||||
FirstOrDefaultValue(first?.ReReleaseYear, second?.ReReleaseYear),
|
||||
FirstOrDefaultReference(first?.ReleaseCountry, second?.ReleaseCountry),
|
||||
FirstOrDefaultReference(first?.ReleaseVersion, second?.ReleaseVersion));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first non-null value of the two reference values.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the reference values.</typeparam>
|
||||
/// <param name="first">The value with priority.</param>
|
||||
/// <param name="second">The fallback value.</param>
|
||||
/// <returns>The first non-null value, or <see langword="null"/> when both are <see langword="null"/>.</returns>
|
||||
private static T? FirstOrDefaultReference<T>(T? first, T? second)
|
||||
where T : class
|
||||
{
|
||||
return first ?? second;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the first non-null value of the two nullable value types.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The underlying type of the nullable values.</typeparam>
|
||||
/// <param name="first">The value with priority.</param>
|
||||
/// <param name="second">The fallback value.</param>
|
||||
/// <returns>The first non-null value, or <see langword="null"/> when both are <see langword="null"/>.</returns>
|
||||
private static T? FirstOrDefaultValue<T>(T? first, T? second)
|
||||
where T : struct
|
||||
{
|
||||
return first ?? second;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the union of the two collections, de-duplicated by the <paramref name="keySelector"/> key, keeping the items of the first collection on key conflicts.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the collection items.</typeparam>
|
||||
/// <param name="first">The first collection, whose items have priority.</param>
|
||||
/// <param name="second">The second collection.</param>
|
||||
/// <param name="keySelector">The function used to extract the de-duplication key of an item.</param>
|
||||
/// <returns>The union of the two collections, or <see langword="null"/> when both are <see langword="null"/>.</returns>
|
||||
private static List<T>? Union<T>(List<T>? first, List<T>? second, Func<T, string?> keySelector)
|
||||
where T : class
|
||||
{
|
||||
if (first is null && second is null)
|
||||
return null;
|
||||
|
||||
Dictionary<string, T> seen = new(StringComparer.OrdinalIgnoreCase);
|
||||
List<T> result = [];
|
||||
|
||||
void AddRange(List<T>? items)
|
||||
{
|
||||
foreach (T item in items ?? [])
|
||||
if (seen.TryAdd(keySelector(item) ?? string.Empty, item))
|
||||
result.Add(item);
|
||||
}
|
||||
|
||||
AddRange(first);
|
||||
AddRange(second);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
{
|
||||
"MediaSettings": {
|
||||
"RootDirectory": "media",
|
||||
"LibrariesDirectory": "libraries"
|
||||
"LibrariesDirectory": "libraries",
|
||||
"BooksDirectory": "books"
|
||||
},
|
||||
"PluginsSettings": {
|
||||
"Directory": "plugins"
|
||||
|
||||
+4
-4
@@ -34,7 +34,7 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
CoverImage: "/media/posters/myPoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: false,
|
||||
DownloadMetadataFromWeb: true,
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false
|
||||
);
|
||||
@@ -45,7 +45,7 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
RequestParam(r => r.CoverImage, "The path of the image file used as the cover for the library. Optional.");
|
||||
RequestParam(r => r.IsEnabled, "Whether this media library is enabled or not. A disabled media library is never shown or changed. Optional.");
|
||||
RequestParam(r => r.IsLocked, "Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. Optional.");
|
||||
RequestParam(r => r.DownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not. Optional.");
|
||||
RequestParam(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not. Optional.");
|
||||
RequestParam(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional.");
|
||||
RequestParam(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional.");
|
||||
|
||||
@@ -57,7 +57,7 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
ResponseParam<LibraryResponse>(r => r.CoverImage, "The path of the image file used as the cover for the library.");
|
||||
ResponseParam<LibraryResponse>(r => r.IsEnabled, "Whether this media library is enabled or not. A disabled media library is never shown or changed.");
|
||||
ResponseParam<LibraryResponse>(r => r.IsLocked, "Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated.");
|
||||
ResponseParam<LibraryResponse>(r => r.DownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
|
||||
@@ -73,7 +73,7 @@ public class AddLibraryEndpointSummary : Summary<AddLibraryEndpoint, AddLibraryR
|
||||
CoverImage: "/media/myPoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: false,
|
||||
DownloadMetadataFromWeb: true,
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ public class GetEnabledLibrariesEndpointSummary : Summary<GetEnabledLibrariesEnd
|
||||
CoverImage: "/media/myTvShowPoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: false,
|
||||
DownloadMetadataFromWeb: true,
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
@@ -48,7 +48,7 @@ public class GetEnabledLibrariesEndpointSummary : Summary<GetEnabledLibrariesEnd
|
||||
CoverImage: "/media/myMoviePoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: true,
|
||||
DownloadMetadataFromWeb: true,
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: true,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
|
||||
+2
-2
@@ -33,7 +33,7 @@ public class GetLibrariesEndpointSummary : Summary<GetLibrariesEndpoint, EmptyRe
|
||||
CoverImage: "/media/myTvShowPoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: false,
|
||||
DownloadMetadataFromWeb: true,
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
@@ -48,7 +48,7 @@ public class GetLibrariesEndpointSummary : Summary<GetLibrariesEndpoint, EmptyRe
|
||||
CoverImage: "/media/myMoviePoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: true,
|
||||
DownloadMetadataFromWeb: true,
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: true,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@ public class GetLibraryEndpointSummary : Summary<GetLibraryEndpoint, GetLibraryR
|
||||
ResponseParam<LibraryResponse>(r => r.CoverImage, "The path of the image file used as the cover for the library.");
|
||||
ResponseParam<LibraryResponse>(r => r.IsEnabled, "Whether this media library is enabled or not. A disabled media library is never shown or changed.");
|
||||
ResponseParam<LibraryResponse>(r => r.IsLocked, "Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated.");
|
||||
ResponseParam<LibraryResponse>(r => r.DownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
|
||||
@@ -53,7 +53,7 @@ public class GetLibraryEndpointSummary : Summary<GetLibraryEndpoint, GetLibraryR
|
||||
CoverImage: "/media/myPoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: false,
|
||||
DownloadMetadataFromWeb: true,
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
|
||||
+4
-4
@@ -36,7 +36,7 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
CoverImage: "/media/posters/myPoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: false,
|
||||
DownloadMetadataFromWeb: true,
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false
|
||||
);
|
||||
@@ -49,7 +49,7 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
RequestParam(r => r.CoverImage, "The path of the image file used as the cover for the library. Optional.");
|
||||
RequestParam(r => r.IsEnabled, "Whether this media library is enabled or not. A disabled media library is never shown or changed. Optional.");
|
||||
RequestParam(r => r.IsLocked, "Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated. Optional.");
|
||||
RequestParam(r => r.DownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not. Optional.");
|
||||
RequestParam(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not. Optional.");
|
||||
RequestParam(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not. Optional.");
|
||||
RequestParam(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not. Optional.");
|
||||
|
||||
@@ -61,7 +61,7 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
ResponseParam<LibraryResponse>(r => r.CoverImage, "The path of the image file used as the cover for the library.");
|
||||
ResponseParam<LibraryResponse>(r => r.IsEnabled, "Whether this media library is enabled or not. A disabled media library is never shown or changed.");
|
||||
ResponseParam<LibraryResponse>(r => r.IsLocked, "Whether this media library is locked or not. A locked media library is displayed, but is never changed or updated.");
|
||||
ResponseParam<LibraryResponse>(r => r.DownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.CanDownloadMetadataFromWeb, "Whether this media library should update the metadata of its elements from the web, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSaveMetadataInMediaDirectories, "Whether this media library should copy the downloaded metadata into the media library content locations, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether this media library should skip the directories whose contents have not changed since the last scan, during the scan, or not.");
|
||||
ResponseParam<LibraryResponse>(r => r.CreatedOnUtc, "The date and time when the entity was created.");
|
||||
@@ -77,7 +77,7 @@ public class UpdateLibraryEndpointSummary : Summary<UpdateLibraryEndpoint, Updat
|
||||
CoverImage: "/media/myPoster.jpg",
|
||||
IsEnabled: true,
|
||||
IsLocked: false,
|
||||
DownloadMetadataFromWeb: true,
|
||||
CanDownloadMetadataFromWeb: true,
|
||||
ShouldSaveMetadataInMediaDirectories: false,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: false,
|
||||
CreatedOnUtc: DateTime.UtcNow,
|
||||
|
||||
+3
-2
@@ -26,8 +26,9 @@ public class GetUserSettingsEndpointSummary : Summary<GetUserSettingsEndpoint, E
|
||||
UserId: Guid.NewGuid(),
|
||||
IsPaginationEnabled: true,
|
||||
ItemsPerPage: 48,
|
||||
IgnoreThePrefixForAlphaPicker: false,
|
||||
IsThemeCachingEnabled: true
|
||||
ShouldIgnoreThePrefixForAlphaPicker: false,
|
||||
IsThemeCachingEnabled: true,
|
||||
ShouldAggregateMetadataWhenMissing: false
|
||||
));
|
||||
|
||||
Response(401, "Authentication required.", "application/problem+json",
|
||||
|
||||
+4
-3
@@ -24,13 +24,14 @@ public class UpdateUserSettingsEndpointSummary : Summary<UpdateUserSettingsEndpo
|
||||
ExampleRequest = new UpdateUserSettingsRequest(
|
||||
IsPaginationEnabled: true,
|
||||
ItemsPerPage: 48,
|
||||
IgnoreThePrefixForAlphaPicker: false,
|
||||
IsThemeCachingEnabled: true
|
||||
ShouldIgnoreThePrefixForAlphaPicker: false,
|
||||
IsThemeCachingEnabled: true,
|
||||
ShouldAggregateMetadataWhenMissing: false
|
||||
);
|
||||
|
||||
RequestParam(r => r.IsPaginationEnabled, "Whether pagination is enabled for the user, or not. Required.");
|
||||
RequestParam(r => r.ItemsPerPage, "The number of library items displayed per page when pagination is enabled. Required.");
|
||||
RequestParam(r => r.IgnoreThePrefixForAlphaPicker, "Whether the \"The\" prefix of library item titles is ignored by the alpha picker, or not. Required.");
|
||||
RequestParam(r => r.ShouldIgnoreThePrefixForAlphaPicker, "Whether the \"The\" prefix of library item titles is ignored by the alpha picker, or not. Required.");
|
||||
RequestParam(r => r.IsThemeCachingEnabled, "Whether the theme data served to this user is cached, or not. Required.");
|
||||
|
||||
Response(200, "The settings of the current user were successfully updated.");
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Presentation.Web.Common.Enums.Library;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -56,7 +55,7 @@ public class LibraryDto
|
||||
/// <summary>
|
||||
/// Gets or sets whether this media library should update the metadata of its elements from the web, or not.
|
||||
/// </summary>
|
||||
public bool DownloadMetadataFromWeb { get; set; } = true;
|
||||
public bool CanDownloadMetadataFromWeb { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether this media library should copy the downloaded metadata into the media library content locations, or not.
|
||||
|
||||
@@ -29,10 +29,15 @@ public class UserSettingsDto
|
||||
/// <summary>
|
||||
/// Gets or sets whether the "The" prefix of library item titles is ignored by the alpha picker, or not.
|
||||
/// </summary>
|
||||
public bool IgnoreThePrefixForAlphaPicker { get; set; }
|
||||
public bool ShouldIgnoreThePrefixForAlphaPicker { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the theme data served to this user is cached, or not.
|
||||
/// </summary>
|
||||
public bool IsThemeCachingEnabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.
|
||||
/// </summary>
|
||||
public bool ShouldAggregateMetadataWhenMissing { get; set; }
|
||||
}
|
||||
+1
-2
@@ -2,7 +2,6 @@
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
@@ -29,7 +28,7 @@ public class SaveLibraryEndpointSummary : Summary<SaveLibraryEndpoint, LibraryDt
|
||||
RequestParam(r => r.ContentLocations, "The collection of directories that contain the media library files. Required.");
|
||||
RequestParam(r => r.IsEnabled, "Whether the media library is enabled or not. Optional.");
|
||||
RequestParam(r => r.IsLocked, "Whether the media library is locked or not. Optional.");
|
||||
RequestParam(r => r.DownloadMetadataFromWeb, "Whether the metadata of the media library items should be downloaded from the web, or not. Optional.");
|
||||
RequestParam(r => r.CanDownloadMetadataFromWeb, "Whether the metadata of the media library items should be downloaded from the web, or not. Optional.");
|
||||
RequestParam(r => r.ShouldSaveMetadataInMediaDirectories, "Whether the downloaded metadata should be copied into the media library content locations, or not. Optional.");
|
||||
RequestParam(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether the directories whose contents have not changed since the last scan should be skipped during the scan, or not. Optional.");
|
||||
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.UsersManagement;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
@@ -23,7 +22,7 @@ public class UpdateUserSettingsEndpointSummary : Summary<UpdateUserSettingsEndpo
|
||||
RequestParam(r => r.UserId, "The unique identifier of the user that owns the settings. Optional.");
|
||||
RequestParam(r => r.IsPaginationEnabled, "Whether pagination is enabled for the user, or not. Optional.");
|
||||
RequestParam(r => r.ItemsPerPage, "The number of library items displayed per page when pagination is enabled. Optional.");
|
||||
RequestParam(r => r.IgnoreThePrefixForAlphaPicker, "Whether the leading 'The' prefix of library item titles is ignored by the alpha picker, or not. Optional.");
|
||||
RequestParam(r => r.ShouldIgnoreThePrefixForAlphaPicker, "Whether the leading 'The' prefix of library item titles is ignored by the alpha picker, or not. Optional.");
|
||||
|
||||
ExampleRequest = new UserSettingsDto();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
@@ -171,7 +171,7 @@
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>حدد المجلدات التي تحتوي على ملفات الوسائط الخاصة بهذه المكتبة</value>
|
||||
</data>
|
||||
<data name="DescriptionDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="DescriptionCanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>ما إذا كانت مكتبة الوسائط هذه ستحصل على البيانات الوصفية لعناصرها عن طريق تنزيلها من الإنترنت أم لا.</value>
|
||||
</data>
|
||||
<data name="DescriptionEnabled" xml:space="preserve">
|
||||
@@ -198,7 +198,7 @@
|
||||
<data name="Documentary" xml:space="preserve">
|
||||
<value>وثائقي</value>
|
||||
</data>
|
||||
<data name="DownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="CanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>تنزيل البيانات الوصفية من الويب</value>
|
||||
</data>
|
||||
<data name="EBook" xml:space="preserve">
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>Wählen Sie die Ordner mit den Mediendateien dieser Bibliothek aus</value>
|
||||
</data>
|
||||
<data name="DescriptionDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="DescriptionCanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>Ob diese Medienbibliothek die Metadaten ihrer Elemente aus dem Internet herunterladen soll oder nicht.</value>
|
||||
</data>
|
||||
<data name="DescriptionEnabled" xml:space="preserve">
|
||||
@@ -198,7 +198,7 @@
|
||||
<data name="Documentary" xml:space="preserve">
|
||||
<value>Dokumentarfilm</value>
|
||||
</data>
|
||||
<data name="DownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="CanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>Metadaten Aus Dem Web Herunterladen</value>
|
||||
</data>
|
||||
<data name="EBook" xml:space="preserve">
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>Select the folders containing the media files of this library</value>
|
||||
</data>
|
||||
<data name="DescriptionDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="DescriptionCanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>Whether this media library should get the metadata of it elements by downloading it from the Internet, or not.</value>
|
||||
</data>
|
||||
<data name="DescriptionEnabled" xml:space="preserve">
|
||||
@@ -198,7 +198,7 @@
|
||||
<data name="Documentary" xml:space="preserve">
|
||||
<value>Documentary</value>
|
||||
</data>
|
||||
<data name="DownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="CanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>Download Metadata From The Web</value>
|
||||
</data>
|
||||
<data name="EBook" xml:space="preserve">
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>Selecciona las carpetas que contienen los archivos multimedia de esta biblioteca</value>
|
||||
</data>
|
||||
<data name="DescriptionDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="DescriptionCanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>Si esta biblioteca multimedia debe obtener los metadatos de sus elementos descargándolos de Internet o no.</value>
|
||||
</data>
|
||||
<data name="DescriptionEnabled" xml:space="preserve">
|
||||
@@ -198,7 +198,7 @@
|
||||
<data name="Documentary" xml:space="preserve">
|
||||
<value>Documental</value>
|
||||
</data>
|
||||
<data name="DownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="CanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>Descargar Metadatos Desde La Web</value>
|
||||
</data>
|
||||
<data name="EBook" xml:space="preserve">
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>Sélectionnez les dossiers contenant les fichiers multimédias de cette bibliothèque</value>
|
||||
</data>
|
||||
<data name="DescriptionDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="DescriptionCanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>Si cette médiathèque doit obtenir les métadonnées de ses éléments en les téléchargeant depuis Internet ou non.</value>
|
||||
</data>
|
||||
<data name="DescriptionEnabled" xml:space="preserve">
|
||||
@@ -198,7 +198,7 @@
|
||||
<data name="Documentary" xml:space="preserve">
|
||||
<value>Documentaire</value>
|
||||
</data>
|
||||
<data name="DownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="CanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>Télécharger Les Métadonnées Depuis Le Web</value>
|
||||
</data>
|
||||
<data name="EBook" xml:space="preserve">
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>Seleziona le cartelle che contengono i file multimediali di questa biblioteca</value>
|
||||
</data>
|
||||
<data name="DescriptionDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="DescriptionCanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>Se questa libreria multimediale deve ottenere i metadati dei suoi elementi scaricandoli da Internet o meno.</value>
|
||||
</data>
|
||||
<data name="DescriptionEnabled" xml:space="preserve">
|
||||
@@ -198,7 +198,7 @@
|
||||
<data name="Documentary" xml:space="preserve">
|
||||
<value>Documentario</value>
|
||||
</data>
|
||||
<data name="DownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="CanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>Scarica I Metadati Dal Web</value>
|
||||
</data>
|
||||
<data name="EBook" xml:space="preserve">
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>このライブラリのメディアファイルを含むフォルダを選択してください</value>
|
||||
</data>
|
||||
<data name="DescriptionDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="DescriptionCanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>このメディアライブラリの要素のメタデータをインターネットからダウンロードして取得するかどうか。</value>
|
||||
</data>
|
||||
<data name="DescriptionEnabled" xml:space="preserve">
|
||||
@@ -198,7 +198,7 @@
|
||||
<data name="Documentary" xml:space="preserve">
|
||||
<value>ドキュメンタリー</value>
|
||||
</data>
|
||||
<data name="DownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="CanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>ウェブからメタデータをダウンロード</value>
|
||||
</data>
|
||||
<data name="EBook" xml:space="preserve">
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>Select the folders containing the media files of this library</value>
|
||||
</data>
|
||||
<data name="DescriptionDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="DescriptionCanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>Whether this media library should get the metadata of it elements by downloading it from the Internet, or not.</value>
|
||||
</data>
|
||||
<data name="DescriptionEnabled" xml:space="preserve">
|
||||
@@ -198,7 +198,7 @@
|
||||
<data name="Documentary" xml:space="preserve">
|
||||
<value>Documentary</value>
|
||||
</data>
|
||||
<data name="DownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="CanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>Download Metadata From The Web</value>
|
||||
</data>
|
||||
<data name="EBook" xml:space="preserve">
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>Selectează dosarele care conțin fișierele media ale acestei biblioteci</value>
|
||||
</data>
|
||||
<data name="DescriptionDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="DescriptionCanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>Dacă această bibliotecă media ar trebui să obțină metadatele elementelor sale prin descărcare de pe Internet sau nu.</value>
|
||||
</data>
|
||||
<data name="DescriptionEnabled" xml:space="preserve">
|
||||
@@ -198,7 +198,7 @@
|
||||
<data name="Documentary" xml:space="preserve">
|
||||
<value>Documentar</value>
|
||||
</data>
|
||||
<data name="DownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="CanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>Descarcă Metadate De Pe Web</value>
|
||||
</data>
|
||||
<data name="EBook" xml:space="preserve">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
@@ -171,7 +171,7 @@
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>Виберіть папки, що містять медіафайли цієї бібліотеки</value>
|
||||
</data>
|
||||
<data name="DescriptionDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="DescriptionCanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>Чи повинна ця медіатека отримувати метадані своїх елементів шляхом завантаження з Інтернету чи ні.</value>
|
||||
</data>
|
||||
<data name="DescriptionEnabled" xml:space="preserve">
|
||||
@@ -198,7 +198,7 @@
|
||||
<data name="Documentary" xml:space="preserve">
|
||||
<value>Документальний фільм</value>
|
||||
</data>
|
||||
<data name="DownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="CanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>Завантажити метадані з Інтернету</value>
|
||||
</data>
|
||||
<data name="EBook" xml:space="preserve">
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
<data name="DescriptionDirectories" xml:space="preserve">
|
||||
<value>选择包含该图书馆媒体文件的文件夹</value>
|
||||
</data>
|
||||
<data name="DescriptionDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="DescriptionCanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>此媒体库是否应该从互联网下载其元素的元数据。</value>
|
||||
</data>
|
||||
<data name="DescriptionEnabled" xml:space="preserve">
|
||||
@@ -198,7 +198,7 @@
|
||||
<data name="Documentary" xml:space="preserve">
|
||||
<value>纪录片</value>
|
||||
</data>
|
||||
<data name="DownloadMetadataFromWeb" xml:space="preserve">
|
||||
<data name="CanDownloadMetadataFromWeb" xml:space="preserve">
|
||||
<value>从网络下载元数据</value>
|
||||
</data>
|
||||
<data name="EBook" xml:space="preserve">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
@@ -21,7 +21,7 @@
|
||||
<data name="ItemsPerPage" xml:space="preserve">
|
||||
<value>عدد العناصر في كل صفحة</value>
|
||||
</data>
|
||||
<data name="IgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="ShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>تجاهل بادئة "The" في أداة الاختيار الأبجدية</value>
|
||||
</data>
|
||||
<data name="Save" xml:space="preserve">
|
||||
@@ -36,7 +36,7 @@
|
||||
<data name="DescriptionItemsPerPage" xml:space="preserve">
|
||||
<value>عدد عناصر المكتبة المعروضة في كل صفحة عند تفعيل ترقيم الصفحات.</value>
|
||||
</data>
|
||||
<data name="DescriptionIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="DescriptionShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>عند التفعيل، يتم تجميع عناصر المكتبة التي يبدأ عنوانها بـ "The" تحت الحرف الأول من الكلمة التالية في أداة الاختيار الأبجدية، على سبيل المثال "The Rasmus" تُدرج تحت حرف R.</value>
|
||||
</data>
|
||||
<data name="EnableThemeCaching" xml:space="preserve">
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<data name="ItemsPerPage" xml:space="preserve">
|
||||
<value>Elemente pro Seite</value>
|
||||
</data>
|
||||
<data name="IgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="ShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>"The"-Präfix für die Alpha-Auswahl ignorieren</value>
|
||||
</data>
|
||||
<data name="Save" xml:space="preserve">
|
||||
@@ -36,7 +36,7 @@
|
||||
<data name="DescriptionItemsPerPage" xml:space="preserve">
|
||||
<value>Die Anzahl der Bibliothekselemente, die bei aktivierter Seitennummerierung auf jeder Seite angezeigt werden.</value>
|
||||
</data>
|
||||
<data name="DescriptionIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="DescriptionShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>Wenn aktiviert, werden Bibliothekselemente, deren Titel mit "The" beginnt, in der Alpha-Auswahl unter dem ersten Buchstaben des folgenden Wortes gruppiert, z. B. wird "The Rasmus" unter R aufgeführt.</value>
|
||||
</data>
|
||||
<data name="EnableThemeCaching" xml:space="preserve">
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<data name="ItemsPerPage" xml:space="preserve">
|
||||
<value>Items per page</value>
|
||||
</data>
|
||||
<data name="IgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="ShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>Ignore "The" prefix for the alpha picker</value>
|
||||
</data>
|
||||
<data name="Save" xml:space="preserve">
|
||||
@@ -36,7 +36,7 @@
|
||||
<data name="DescriptionItemsPerPage" xml:space="preserve">
|
||||
<value>The number of library items displayed on each page when pagination is enabled.</value>
|
||||
</data>
|
||||
<data name="DescriptionIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="DescriptionShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>When enabled, library items whose title begins with "The" are grouped under the first letter of the following word in the alpha picker, e.g. "The Rasmus" is listed under R.</value>
|
||||
</data>
|
||||
<data name="EnableThemeCaching" xml:space="preserve">
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<data name="ItemsPerPage" xml:space="preserve">
|
||||
<value>Elementos por página</value>
|
||||
</data>
|
||||
<data name="IgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="ShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>Ignorar el prefijo "The" en el selector alfabético</value>
|
||||
</data>
|
||||
<data name="Save" xml:space="preserve">
|
||||
@@ -36,7 +36,7 @@
|
||||
<data name="DescriptionItemsPerPage" xml:space="preserve">
|
||||
<value>El número de elementos de la biblioteca mostrados en cada página cuando la paginación está habilitada.</value>
|
||||
</data>
|
||||
<data name="DescriptionIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="DescriptionShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>Cuando está habilitado, los elementos de la biblioteca cuyo título comienza con "The" se agrupan bajo la primera letra de la palabra siguiente en el selector alfabético, por ejemplo, "The Rasmus" se lista bajo R.</value>
|
||||
</data>
|
||||
<data name="EnableThemeCaching" xml:space="preserve">
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<data name="ItemsPerPage" xml:space="preserve">
|
||||
<value>Éléments par page</value>
|
||||
</data>
|
||||
<data name="IgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="ShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>Ignorer le préfixe "The" dans le sélecteur alphabétique</value>
|
||||
</data>
|
||||
<data name="Save" xml:space="preserve">
|
||||
@@ -36,7 +36,7 @@
|
||||
<data name="DescriptionItemsPerPage" xml:space="preserve">
|
||||
<value>Le nombre d'éléments de la bibliothèque affichés sur chaque page lorsque la pagination est activée.</value>
|
||||
</data>
|
||||
<data name="DescriptionIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="DescriptionShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>Lorsque cette option est activée, les éléments de la bibliothèque dont le titre commence par "The" sont regroupés sous la première lettre du mot suivant dans le sélecteur alphabétique, par exemple "The Rasmus" est répertorié sous R.</value>
|
||||
</data>
|
||||
<data name="EnableThemeCaching" xml:space="preserve">
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<data name="ItemsPerPage" xml:space="preserve">
|
||||
<value>Elementi per pagina</value>
|
||||
</data>
|
||||
<data name="IgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="ShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>Ignora il prefisso "The" nel selettore alfabetico</value>
|
||||
</data>
|
||||
<data name="Save" xml:space="preserve">
|
||||
@@ -36,7 +36,7 @@
|
||||
<data name="DescriptionItemsPerPage" xml:space="preserve">
|
||||
<value>Il numero di elementi della libreria visualizzati su ogni pagina quando la paginazione è abilitata.</value>
|
||||
</data>
|
||||
<data name="DescriptionIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="DescriptionShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>Se abilitato, gli elementi della libreria il cui titolo inizia con "The" vengono raggruppati sotto la prima lettera della parola successiva nel selettore alfabetico, ad esempio "The Rasmus" è elencato sotto R.</value>
|
||||
</data>
|
||||
<data name="EnableThemeCaching" xml:space="preserve">
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<data name="ItemsPerPage" xml:space="preserve">
|
||||
<value>ページあたりの項目数</value>
|
||||
</data>
|
||||
<data name="IgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="ShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>アルファピッカーで「The」の接頭辞を無視する</value>
|
||||
</data>
|
||||
<data name="Save" xml:space="preserve">
|
||||
@@ -36,7 +36,7 @@
|
||||
<data name="DescriptionItemsPerPage" xml:space="preserve">
|
||||
<value>ページネーションが有効な場合に各ページに表示されるライブラリの項目数。</value>
|
||||
</data>
|
||||
<data name="DescriptionIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="DescriptionShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>有効にすると、タイトルが「The」で始まるライブラリの項目は、アルファピッカーで次の単語の最初の文字の下にグループ化されます。たとえば「The Rasmus」は「R」の下に表示されます。</value>
|
||||
</data>
|
||||
<data name="EnableThemeCaching" xml:space="preserve">
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<data name="ItemsPerPage" xml:space="preserve">
|
||||
<value>Items per page</value>
|
||||
</data>
|
||||
<data name="IgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="ShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>Ignore "The" prefix for the alpha picker</value>
|
||||
</data>
|
||||
<data name="Save" xml:space="preserve">
|
||||
@@ -36,7 +36,7 @@
|
||||
<data name="DescriptionItemsPerPage" xml:space="preserve">
|
||||
<value>The number of library items displayed on each page when pagination is enabled.</value>
|
||||
</data>
|
||||
<data name="DescriptionIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="DescriptionShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>When enabled, library items whose title begins with "The" are grouped under the first letter of the following word in the alpha picker, e.g. "The Rasmus" is listed under R.</value>
|
||||
</data>
|
||||
<data name="EnableThemeCaching" xml:space="preserve">
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<data name="ItemsPerPage" xml:space="preserve">
|
||||
<value>Elemente pe pagină</value>
|
||||
</data>
|
||||
<data name="IgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="ShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>Ignorați prefixul "The" pentru selectorul alfabetic</value>
|
||||
</data>
|
||||
<data name="Save" xml:space="preserve">
|
||||
@@ -36,7 +36,7 @@
|
||||
<data name="DescriptionItemsPerPage" xml:space="preserve">
|
||||
<value>Numărul de elemente ale bibliotecii afișate pe fiecare pagină atunci când paginarea este activată.</value>
|
||||
</data>
|
||||
<data name="DescriptionIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="DescriptionShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>Când este activată, elementele bibliotecii al căror titlu începe cu "The" sunt grupate sub prima literă a cuvântului următor în selectorul alfabetic, de exemplu "The Rasmus" este listat sub R.</value>
|
||||
</data>
|
||||
<data name="EnableThemeCaching" xml:space="preserve">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
@@ -21,7 +21,7 @@
|
||||
<data name="ItemsPerPage" xml:space="preserve">
|
||||
<value>Елементів на сторінці</value>
|
||||
</data>
|
||||
<data name="IgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="ShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>Ігнорувати префікс "The" в алфавітному покажчику</value>
|
||||
</data>
|
||||
<data name="Save" xml:space="preserve">
|
||||
@@ -36,7 +36,7 @@
|
||||
<data name="DescriptionItemsPerPage" xml:space="preserve">
|
||||
<value>Кількість елементів бібліотеки, що відображаються на кожній сторінці за увімкненої розбивки на сторінки.</value>
|
||||
</data>
|
||||
<data name="DescriptionIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="DescriptionShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>За увімкнення елементи бібліотеки, назва яких починається з "The", групуються в алфавітному покажчику під першою літерою наступного слова, наприклад "The Rasmus" відображається під літерою R.</value>
|
||||
</data>
|
||||
<data name="EnableThemeCaching" xml:space="preserve">
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<data name="ItemsPerPage" xml:space="preserve">
|
||||
<value>每页项目数</value>
|
||||
</data>
|
||||
<data name="IgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="ShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>在字母选择器中忽略“The”前缀</value>
|
||||
</data>
|
||||
<data name="Save" xml:space="preserve">
|
||||
@@ -36,7 +36,7 @@
|
||||
<data name="DescriptionItemsPerPage" xml:space="preserve">
|
||||
<value>启用分页时每页显示的库项目数。</value>
|
||||
</data>
|
||||
<data name="DescriptionIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<data name="DescriptionShouldIgnoreThePrefixForAlphaPicker" xml:space="preserve">
|
||||
<value>启用后,标题以"The"开头的库项目将在字母选择器中按后一个词的首字母分组,例如"The Rasmus"会列在R下。</value>
|
||||
</data>
|
||||
<data name="EnableThemeCaching" xml:space="preserve">
|
||||
|
||||
@@ -170,15 +170,15 @@
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-label">
|
||||
<label asp-for="DownloadMetadataFromWeb">@_localizer["DownloadMetadataFromWeb"]</label>:
|
||||
<label asp-for="CanDownloadMetadataFromWeb">@_localizer["CanDownloadMetadataFromWeb"]</label>:
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label class="enlightenment-checkbox-label">
|
||||
<input type="checkbox" asp-for="DownloadMetadataFromWeb" class="enlightenment-checkbox-hidden"/>
|
||||
<input type="checkbox" asp-for="CanDownloadMetadataFromWeb" class="enlightenment-checkbox-hidden"/>
|
||||
<span class="enlightenment-checkbox"></span>
|
||||
</label>
|
||||
</div>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionDownloadMetadataFromWeb"]</small>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionCanDownloadMetadataFromWeb"]</small>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-label">
|
||||
@@ -251,7 +251,7 @@
|
||||
const mediaDirectoriesFormTable = document.getElementById('add-media-directory-form-table');
|
||||
const chkIsEnabled = form.querySelector('[name="IsEnabled"]');
|
||||
const chkIsLocked = form.querySelector('[name="IsLocked"]');
|
||||
const chkDownloadMetadataFromWeb = form.querySelector('[name="DownloadMetadataFromWeb"]');
|
||||
const chkCanDownloadMetadataFromWeb = form.querySelector('[name="CanDownloadMetadataFromWeb"]');
|
||||
const chkShouldSaveMetadataInMediaDirectories = form.querySelector('[name="ShouldSaveMetadataInMediaDirectories"]');
|
||||
const chkShouldSkipUnchangedDirectoriesDuringScan = form.querySelector('[name="ShouldSkipUnchangedDirectoriesDuringScan"]');
|
||||
|
||||
@@ -271,7 +271,7 @@
|
||||
})(),
|
||||
IsEnabled: chkIsEnabled.checked,
|
||||
IsLocked: chkIsLocked.checked,
|
||||
DownloadMetadataFromWeb: chkDownloadMetadataFromWeb.checked,
|
||||
CanDownloadMetadataFromWeb: chkCanDownloadMetadataFromWeb.checked,
|
||||
ShouldSaveMetadataInMediaDirectories: chkShouldSaveMetadataInMediaDirectories.checked,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan: chkShouldSkipUnchangedDirectoriesDuringScan.checked
|
||||
};
|
||||
|
||||
@@ -55,15 +55,15 @@
|
||||
<!-- Alpha picker -->
|
||||
<div class="form-row">
|
||||
<div class="form-label">
|
||||
<label asp-for="IgnoreThePrefixForAlphaPicker">@_localizer["IgnoreThePrefixForAlphaPicker"]</label>:
|
||||
<label asp-for="ShouldIgnoreThePrefixForAlphaPicker">@_localizer["ShouldIgnoreThePrefixForAlphaPicker"]</label>:
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label class="enlightenment-checkbox-label">
|
||||
<input type="checkbox" asp-for="IgnoreThePrefixForAlphaPicker" class="enlightenment-checkbox-hidden" />
|
||||
<input type="checkbox" asp-for="ShouldIgnoreThePrefixForAlphaPicker" class="enlightenment-checkbox-hidden" />
|
||||
<span class="enlightenment-checkbox"></span>
|
||||
</label>
|
||||
</div>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionIgnoreThePrefixForAlphaPicker"]</small>
|
||||
<small class="form-label text-disabled form-description">@_localizer["DescriptionShouldIgnoreThePrefixForAlphaPicker"]</small>
|
||||
</div>
|
||||
<!-- Theme caching -->
|
||||
<div class="form-row">
|
||||
@@ -94,8 +94,9 @@
|
||||
const form = document.getElementById('user-settings-form');
|
||||
const checkboxIsPaginationEnabled = document.getElementById('IsPaginationEnabled');
|
||||
const inputItemsPerPage = document.getElementById('ItemsPerPage');
|
||||
const checkboxIgnoreThePrefixForAlphaPicker = document.getElementById('IgnoreThePrefixForAlphaPicker');
|
||||
const checkboxShouldIgnoreThePrefixForAlphaPicker = document.getElementById('ShouldIgnoreThePrefixForAlphaPicker');
|
||||
const checkboxIsThemeCachingEnabled = document.getElementById('IsThemeCachingEnabled');
|
||||
let shouldAggregateMetadataWhenMissing = false;
|
||||
|
||||
// toggle the enabled state of the items per page input based on the pagination checkbox
|
||||
function updateItemsPerPageEnabledState() {
|
||||
@@ -108,8 +109,9 @@
|
||||
if (data) {
|
||||
checkboxIsPaginationEnabled.checked = data.isPaginationEnabled === true;
|
||||
inputItemsPerPage.value = data.itemsPerPage;
|
||||
checkboxIgnoreThePrefixForAlphaPicker.checked = data.ignoreThePrefixForAlphaPicker === true;
|
||||
checkboxShouldIgnoreThePrefixForAlphaPicker.checked = data.shouldIgnoreThePrefixForAlphaPicker === true;
|
||||
checkboxIsThemeCachingEnabled.checked = data.isThemeCachingEnabled === true;
|
||||
shouldAggregateMetadataWhenMissing = data.shouldAggregateMetadataWhenMissing === true;
|
||||
updateItemsPerPageEnabledState();
|
||||
}
|
||||
}
|
||||
@@ -119,8 +121,9 @@
|
||||
const formData = {
|
||||
IsPaginationEnabled: checkboxIsPaginationEnabled.checked,
|
||||
ItemsPerPage: Number(inputItemsPerPage.value),
|
||||
IgnoreThePrefixForAlphaPicker: checkboxIgnoreThePrefixForAlphaPicker.checked,
|
||||
IsThemeCachingEnabled: checkboxIsThemeCachingEnabled.checked
|
||||
ShouldIgnoreThePrefixForAlphaPicker: checkboxShouldIgnoreThePrefixForAlphaPicker.checked,
|
||||
IsThemeCachingEnabled: checkboxIsThemeCachingEnabled.checked,
|
||||
ShouldAggregateMetadataWhenMissing: shouldAggregateMetadataWhenMissing
|
||||
};
|
||||
const data = await callApiPostAsync('@_urlService.GetAbsoluteUrl(WebRoutes.Settings.UPDATE_USER_SETTINGS)', formData);
|
||||
if (data && data.isUpdated === true)
|
||||
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryContentLocationEntity"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryContentLocationEntityFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryContentLocationEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="path">Optional. The path of the media library content location.</param>
|
||||
/// <returns>The created <see cref="LibraryContentLocationEntity"/>.</returns>
|
||||
public LibraryContentLocationEntity Create(
|
||||
string? path = null)
|
||||
{
|
||||
return new LibraryContentLocationEntity
|
||||
{
|
||||
Path = path ?? _faker.System.DirectoryPath()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryContentLocationEntity"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="LibraryContentLocationEntity"/> instances.</returns>
|
||||
public List<LibraryContentLocationEntity> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -27,7 +27,7 @@ public class LibraryEntityFixture
|
||||
/// <param name="coverImage">Optional. The cover image path of the media library.</param>
|
||||
/// <param name="isEnabled">Whether the media library is enabled or not.</param>
|
||||
/// <param name="isLocked">Whether the media library is locked or not.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether the metadata should be saved in the media directories or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during a scan or not.</param>
|
||||
/// <returns>The created media library entity.</returns>
|
||||
@@ -40,7 +40,7 @@ public class LibraryEntityFixture
|
||||
string? coverImage = null,
|
||||
bool isEnabled = true,
|
||||
bool isLocked = false,
|
||||
bool downloadMetadataFromWeb = true,
|
||||
bool canDownloadMetadataFromWeb = true,
|
||||
bool shouldSaveMetadataInMediaDirectories = true,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false)
|
||||
{
|
||||
@@ -56,7 +56,7 @@ public class LibraryEntityFixture
|
||||
LibraryScans = [],
|
||||
IsEnabled = isEnabled,
|
||||
IsLocked = isLocked,
|
||||
DownloadMetadataFromWeb = downloadMetadataFromWeb,
|
||||
CanDownloadMetadataFromWeb = canDownloadMetadataFromWeb,
|
||||
ShouldSaveMetadataInMediaDirectories = shouldSaveMetadataInMediaDirectories,
|
||||
ShouldSkipUnchangedDirectoriesDuringScan = shouldSkipUnchangedDirectoriesDuringScan,
|
||||
CreatedOnUtc = default,
|
||||
|
||||
+7
-2
@@ -21,14 +21,19 @@ public class LibraryMetadataProviderConfigurationEntityFixture
|
||||
/// <param name="libraryId">The Id of the media library the configuration belongs to.</param>
|
||||
/// <param name="pluginId">The Id of the plugin providing the metadata.</param>
|
||||
/// <param name="rank">The rank of the metadata provider, determining the order in which providers are tried.</param>
|
||||
/// <param name="isEnabled">Whether the metadata provider is enabled or not.</param>
|
||||
/// <returns>The created <see cref="LibraryMetadataProviderConfigurationEntity"/>.</returns>
|
||||
public LibraryMetadataProviderConfigurationEntity Create(Guid libraryId, Guid pluginId, int rank)
|
||||
public LibraryMetadataProviderConfigurationEntity Create(
|
||||
Guid libraryId,
|
||||
Guid pluginId,
|
||||
int rank,
|
||||
bool isEnabled = true)
|
||||
{
|
||||
return new Faker<LibraryMetadataProviderConfigurationEntity>()
|
||||
.RuleFor(configuration => configuration.Id, faker => faker.Random.Guid())
|
||||
.RuleFor(configuration => configuration.LibraryId, libraryId)
|
||||
.RuleFor(configuration => configuration.PluginId, pluginId)
|
||||
.RuleFor(configuration => configuration.IsEnabled, faker => faker.Random.Bool())
|
||||
.RuleFor(configuration => configuration.IsEnabled, isEnabled)
|
||||
.RuleFor(configuration => configuration.Rank, rank)
|
||||
.RuleFor(configuration => configuration.CreatedOnUtc, faker => faker.Date.Past())
|
||||
.RuleFor(configuration => configuration.CreatedBy, faker => faker.Random.Guid())
|
||||
|
||||
+13
-4
@@ -21,17 +21,26 @@ public class PluginEntityFixture
|
||||
/// Creates a random valid <see cref="PluginEntity"/>.
|
||||
/// </summary>
|
||||
/// <param name="id">The Id of the plugin, or <see langword="null"/> to generate a random one.</param>
|
||||
/// <param name="name">The name of the plugin, or <see langword="null"/> to generate a random one.</param>
|
||||
/// <param name="loadStatus">The load status of the plugin, or <see langword="null"/> to generate a random one.</param>
|
||||
/// <param name="settingsJson">The serialized settings of the plugin, or <see langword="null"/> to generate random ones.</param>
|
||||
/// <param name="includeSettingsJson">Whether the settings should be included, or forced to <see langword="null"/>.</param>
|
||||
/// <returns>The created <see cref="PluginEntity"/>.</returns>
|
||||
public PluginEntity Create(Guid? id = null)
|
||||
public PluginEntity Create(
|
||||
Guid? id = null,
|
||||
string? name = null,
|
||||
PluginLoadStatus? loadStatus = null,
|
||||
string? settingsJson = null,
|
||||
bool includeSettingsJson = true)
|
||||
{
|
||||
return new Faker<PluginEntity>()
|
||||
.RuleFor(plugin => plugin.Id, faker => id ?? faker.Random.Guid())
|
||||
.RuleFor(plugin => plugin.Name, faker => faker.Company.CompanyName())
|
||||
.RuleFor(plugin => plugin.Name, faker => name ?? faker.Company.CompanyName())
|
||||
.RuleFor(plugin => plugin.Author, faker => faker.Name.FullName())
|
||||
.RuleFor(plugin => plugin.Version, faker => faker.System.Semver())
|
||||
.RuleFor(plugin => plugin.Description, faker => faker.Lorem.Sentence())
|
||||
.RuleFor(plugin => plugin.LoadStatus, faker => faker.PickRandom<PluginLoadStatus>())
|
||||
.RuleFor(plugin => plugin.SettingsJson, faker => JsonSerializer.Serialize(new Dictionary<string, string> { [faker.Random.String2(1, 10)] = faker.Random.String2(1, 20) }))
|
||||
.RuleFor(plugin => plugin.LoadStatus, faker => loadStatus ?? faker.PickRandom<PluginLoadStatus>())
|
||||
.RuleFor(plugin => plugin.SettingsJson, faker => includeSettingsJson ? settingsJson ?? JsonSerializer.Serialize(new Dictionary<string, string> { [faker.Random.String2(1, 10)] = faker.Random.String2(1, 20) }) : null)
|
||||
.RuleFor(plugin => plugin.CreatedOnUtc, faker => faker.Date.Past())
|
||||
.RuleFor(plugin => plugin.CreatedBy, faker => faker.Random.Guid())
|
||||
.RuleFor(plugin => plugin.UpdatedOnUtc, faker => faker.Date.Recent())
|
||||
|
||||
+8
-5
@@ -22,16 +22,18 @@ public class UserSettingsEntityFixture
|
||||
/// <param name="userId">Optional. The Id of the user that owns these settings.</param>
|
||||
/// <param name="isPaginationEnabled">Optional. Whether pagination is enabled for the user, or not.</param>
|
||||
/// <param name="itemsPerPage">Optional. The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">Optional. Whether the "The" prefix is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Optional. Whether the "The" prefix is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="isThemeCachingEnabled">Optional. Whether the theme data served to this user is cached, or not.</param>
|
||||
/// <param name="shouldAggregateMetadataWhenMissing">Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
|
||||
/// <returns>The created user settings entity.</returns>
|
||||
public UserSettingsEntity Create(
|
||||
Guid? id = null,
|
||||
Guid? userId = null,
|
||||
bool? isPaginationEnabled = null,
|
||||
int? itemsPerPage = null,
|
||||
bool? ignoreThePrefixForAlphaPicker = null,
|
||||
bool? isThemeCachingEnabled = null)
|
||||
bool? shouldIgnoreThePrefixForAlphaPicker = null,
|
||||
bool? isThemeCachingEnabled = null,
|
||||
bool? shouldAggregateMetadataWhenMissing = null)
|
||||
{
|
||||
return new Faker<UserSettingsEntity>()
|
||||
.CustomInstantiator(f => new UserSettingsEntity
|
||||
@@ -40,8 +42,9 @@ public class UserSettingsEntityFixture
|
||||
UserId = userId ?? Guid.NewGuid(),
|
||||
IsPaginationEnabled = isPaginationEnabled ?? f.Random.Bool(),
|
||||
ItemsPerPage = itemsPerPage ?? f.Random.Int(1, 100),
|
||||
IgnoreThePrefixForAlphaPicker = ignoreThePrefixForAlphaPicker ?? f.Random.Bool(),
|
||||
IsThemeCachingEnabled = isThemeCachingEnabled ?? f.Random.Bool()
|
||||
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker ?? f.Random.Bool(),
|
||||
IsThemeCachingEnabled = isThemeCachingEnabled ?? f.Random.Bool(),
|
||||
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing ?? f.Random.Bool()
|
||||
})
|
||||
.Generate();
|
||||
}
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Application.Common.Infrastructure.Models.DTO.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Fixtures.Common.Infrastructure.Models.DTO.Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="MediaSettingsDto"/> class.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class MediaSettingsDtoFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="MediaSettingsDto"/>.
|
||||
/// </summary>
|
||||
/// <param name="rootDirectory">Optional. The root directory where media files are stored.</param>
|
||||
/// <param name="librariesDirectory">Optional. The directory where media library files are stored.</param>
|
||||
/// <param name="booksDirectory">Optional. The directory where the media item files are stored.</param>
|
||||
/// <returns>The created <see cref="MediaSettingsDto"/>.</returns>
|
||||
public MediaSettingsDto Create(
|
||||
string? rootDirectory = null,
|
||||
string? librariesDirectory = null,
|
||||
string? booksDirectory = null)
|
||||
{
|
||||
return new MediaSettingsDto
|
||||
{
|
||||
RootDirectory = rootDirectory ?? _faker.System.DirectoryPath(),
|
||||
LibrariesDirectory = librariesDirectory ?? _faker.System.DirectoryPath(),
|
||||
BooksDirectory = booksDirectory ?? _faker.System.DirectoryPath()
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="MediaSettingsDto"/> instances with randomized test data.
|
||||
/// </summary>
|
||||
/// <param name="count">Number of instances to create.</param>
|
||||
/// <returns>List of configured <see cref="MediaSettingsDto"/> instances.</returns>
|
||||
public List<MediaSettingsDto> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -2,7 +2,6 @@
|
||||
using Bogus;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
@@ -25,7 +24,7 @@ public class AddLibraryCommandFixture
|
||||
/// <param name="coverImage">Optional. The cover image path of the media library.</param>
|
||||
/// <param name="isEnabled">Whether the media library is enabled or not.</param>
|
||||
/// <param name="isLocked">Whether the media library is locked or not.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether the metadata should be saved in the media directories or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during a scan or not.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
@@ -36,7 +35,7 @@ public class AddLibraryCommandFixture
|
||||
string? coverImage = null,
|
||||
bool isEnabled = true,
|
||||
bool isLocked = false,
|
||||
bool downloadMetadataFromWeb = true,
|
||||
bool canDownloadMetadataFromWeb = true,
|
||||
bool shouldSaveMetadataInMediaDirectories = true,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false)
|
||||
{
|
||||
@@ -58,7 +57,7 @@ public class AddLibraryCommandFixture
|
||||
.RuleFor(x => x.CoverImage, f => coverImage ?? f.System.FilePath())
|
||||
.RuleFor(x => x.IsEnabled, isEnabled)
|
||||
.RuleFor(x => x.IsLocked, isLocked)
|
||||
.RuleFor(x => x.DownloadMetadataFromWeb, downloadMetadataFromWeb)
|
||||
.RuleFor(x => x.CanDownloadMetadataFromWeb, canDownloadMetadataFromWeb)
|
||||
.RuleFor(x => x.ShouldSaveMetadataInMediaDirectories, shouldSaveMetadataInMediaDirectories)
|
||||
.RuleFor(x => x.ShouldSkipUnchangedDirectoriesDuringScan, shouldSkipUnchangedDirectoriesDuringScan)
|
||||
.Generate();
|
||||
|
||||
+3
-3
@@ -27,7 +27,7 @@ public class UpdateLibraryCommandFixture
|
||||
/// <param name="coverImage">Optional. The cover image path of the media library.</param>
|
||||
/// <param name="isEnabled">Whether the media library is enabled or not.</param>
|
||||
/// <param name="isLocked">Whether the media library is locked or not.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Whether the media library should download metadata from the web or not.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Whether the metadata should be saved in the media directories or not.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Whether unchanged directories should be skipped during a scan or not.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
@@ -40,7 +40,7 @@ public class UpdateLibraryCommandFixture
|
||||
string? coverImage = null,
|
||||
bool isEnabled = true,
|
||||
bool isLocked = false,
|
||||
bool downloadMetadataFromWeb = true,
|
||||
bool canDownloadMetadataFromWeb = true,
|
||||
bool shouldSaveMetadataInMediaDirectories = true,
|
||||
bool shouldSkipUnchangedDirectoriesDuringScan = false)
|
||||
{
|
||||
@@ -66,7 +66,7 @@ public class UpdateLibraryCommandFixture
|
||||
.RuleFor(x => x.CoverImage, f => coverImage ?? f.System.FilePath())
|
||||
.RuleFor(x => x.IsEnabled, isEnabled)
|
||||
.RuleFor(x => x.IsLocked, isLocked)
|
||||
.RuleFor(x => x.DownloadMetadataFromWeb, downloadMetadataFromWeb)
|
||||
.RuleFor(x => x.CanDownloadMetadataFromWeb, canDownloadMetadataFromWeb)
|
||||
.RuleFor(x => x.ShouldSaveMetadataInMediaDirectories, shouldSaveMetadataInMediaDirectories)
|
||||
.RuleFor(x => x.ShouldSkipUnchangedDirectoriesDuringScan, shouldSkipUnchangedDirectoriesDuringScan)
|
||||
.Generate();
|
||||
|
||||
+7
-5
@@ -19,21 +19,23 @@ public class UpdateUserSettingsCommandFixture
|
||||
/// </summary>
|
||||
/// <param name="isPaginationEnabled">Optional. Whether pagination is enabled for the user, or not.</param>
|
||||
/// <param name="itemsPerPage">Optional. The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="ignoreThePrefixForAlphaPicker">Optional. Whether the "The" prefix is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Optional. Whether the "The" prefix is ignored by the alpha picker, or not.</param>
|
||||
/// <param name="isThemeCachingEnabled">Optional. Whether the theme data served to this user is cached, or not.</param>
|
||||
/// <returns>The created command.</returns>
|
||||
public UpdateUserSettingsCommand Create(
|
||||
bool? isPaginationEnabled = null,
|
||||
int? itemsPerPage = null,
|
||||
bool? ignoreThePrefixForAlphaPicker = null,
|
||||
bool? isThemeCachingEnabled = null)
|
||||
bool? shouldIgnoreThePrefixForAlphaPicker = null,
|
||||
bool? isThemeCachingEnabled = null,
|
||||
bool? shouldAggregateMetadataWhenMissing = null)
|
||||
{
|
||||
return new Faker<UpdateUserSettingsCommand>()
|
||||
.CustomInstantiator(f => new UpdateUserSettingsCommand(default, default, default, default))
|
||||
.CustomInstantiator(f => new UpdateUserSettingsCommand(default, default, default, default, default))
|
||||
.RuleFor(x => x.IsPaginationEnabled, f => isPaginationEnabled ?? f.Random.Bool())
|
||||
.RuleFor(x => x.ItemsPerPage, f => itemsPerPage ?? f.Random.Int(1, 100))
|
||||
.RuleFor(x => x.IgnoreThePrefixForAlphaPicker, f => ignoreThePrefixForAlphaPicker ?? f.Random.Bool())
|
||||
.RuleFor(x => x.ShouldIgnoreThePrefixForAlphaPicker, f => shouldIgnoreThePrefixForAlphaPicker ?? f.Random.Bool())
|
||||
.RuleFor(x => x.IsThemeCachingEnabled, f => isThemeCachingEnabled ?? f.Random.Bool())
|
||||
.RuleFor(x => x.ShouldAggregateMetadataWhenMissing, f => shouldAggregateMetadataWhenMissing ?? f.Random.Bool())
|
||||
.Generate();
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -1,7 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.MediaLibrary.Management;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
@@ -26,7 +25,7 @@ public class AddLibraryRequestFixture
|
||||
/// <param name="coverImage">Optional. The path of the image file used as the cover.</param>
|
||||
/// <param name="isEnabled">Optional. Whether the media library is enabled.</param>
|
||||
/// <param name="isLocked">Optional. Whether the media library is locked.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Optional. Whether metadata should be downloaded from the web.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Optional. Whether metadata should be downloaded from the web.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Optional. Whether metadata should be saved in the media directories.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Optional. Whether unchanged directories should be skipped during scan.</param>
|
||||
/// <returns>The created <see cref="AddLibraryRequest"/>.</returns>
|
||||
@@ -37,7 +36,7 @@ public class AddLibraryRequestFixture
|
||||
string? coverImage = null,
|
||||
bool? isEnabled = null,
|
||||
bool? isLocked = null,
|
||||
bool? downloadMetadataFromWeb = null,
|
||||
bool? canDownloadMetadataFromWeb = null,
|
||||
bool? shouldSaveMetadataInMediaDirectories = null,
|
||||
bool? shouldSkipUnchangedDirectoriesDuringScan = null)
|
||||
{
|
||||
@@ -48,7 +47,7 @@ public class AddLibraryRequestFixture
|
||||
coverImage ?? null,
|
||||
isEnabled ?? _faker.Random.Bool(),
|
||||
isLocked ?? _faker.Random.Bool(),
|
||||
downloadMetadataFromWeb ?? _faker.Random.Bool(),
|
||||
canDownloadMetadataFromWeb ?? _faker.Random.Bool(),
|
||||
shouldSaveMetadataInMediaDirectories ?? _faker.Random.Bool(),
|
||||
shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool()
|
||||
);
|
||||
|
||||
+3
-3
@@ -28,7 +28,7 @@ public class UpdateLibraryRequestFixture
|
||||
/// <param name="coverImage">Optional. The path of the image file used as the cover.</param>
|
||||
/// <param name="isEnabled">Optional. Whether the media library is enabled.</param>
|
||||
/// <param name="isLocked">Optional. Whether the media library is locked.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Optional. Whether metadata should be downloaded from the web.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Optional. Whether metadata should be downloaded from the web.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Optional. Whether metadata should be saved in the media directories.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Optional. Whether unchanged directories should be skipped during scan.</param>
|
||||
/// <returns>The created <see cref="UpdateLibraryRequest"/>.</returns>
|
||||
@@ -41,7 +41,7 @@ public class UpdateLibraryRequestFixture
|
||||
string? coverImage = null,
|
||||
bool? isEnabled = null,
|
||||
bool? isLocked = null,
|
||||
bool? downloadMetadataFromWeb = null,
|
||||
bool? canDownloadMetadataFromWeb = null,
|
||||
bool? shouldSaveMetadataInMediaDirectories = null,
|
||||
bool? shouldSkipUnchangedDirectoriesDuringScan = null)
|
||||
{
|
||||
@@ -54,7 +54,7 @@ public class UpdateLibraryRequestFixture
|
||||
coverImage ?? null,
|
||||
isEnabled ?? _faker.Random.Bool(),
|
||||
isLocked ?? _faker.Random.Bool(),
|
||||
downloadMetadataFromWeb ?? _faker.Random.Bool(),
|
||||
canDownloadMetadataFromWeb ?? _faker.Random.Bool(),
|
||||
shouldSaveMetadataInMediaDirectories ?? _faker.Random.Bool(),
|
||||
shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool()
|
||||
);
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Requests.UsersManagement.Settings;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Requests.UsersManagement.Settings;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UpdateUserSettingsRequest"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdateUserSettingsRequestFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="UpdateUserSettingsRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="isPaginationEnabled">Whether pagination is enabled for the user.</param>
|
||||
/// <param name="itemsPerPage">The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix is ignored by the alpha picker.</param>
|
||||
/// <param name="isThemeCachingEnabled">Whether the theme data served to this user is cached.</param>
|
||||
/// <param name="shouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
|
||||
/// <returns>The created <see cref="UpdateUserSettingsRequest"/>.</returns>
|
||||
public UpdateUserSettingsRequest Create(
|
||||
bool? isPaginationEnabled = null,
|
||||
int? itemsPerPage = null,
|
||||
bool? shouldIgnoreThePrefixForAlphaPicker = null,
|
||||
bool? isThemeCachingEnabled = null,
|
||||
bool? shouldAggregateMetadataWhenMissing = null)
|
||||
{
|
||||
return new UpdateUserSettingsRequest(
|
||||
isPaginationEnabled ?? _faker.Random.Bool(),
|
||||
itemsPerPage ?? _faker.Random.Int(1, 100),
|
||||
shouldIgnoreThePrefixForAlphaPicker ?? _faker.Random.Bool(),
|
||||
isThemeCachingEnabled ?? _faker.Random.Bool(),
|
||||
shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UpdateUserSettingsRequest"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<UpdateUserSettingsRequest> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -29,7 +29,7 @@ public class LibraryResponseFixture
|
||||
/// <param name="coverImage">Optional. The path of the image file used as the cover of the library.</param>
|
||||
/// <param name="isEnabled">Optional. Whether the media library is enabled.</param>
|
||||
/// <param name="isLocked">Optional. Whether the media library is locked.</param>
|
||||
/// <param name="downloadMetadataFromWeb">Optional. Whether metadata should be downloaded from the web.</param>
|
||||
/// <param name="canDownloadMetadataFromWeb">Optional. Whether metadata should be downloaded from the web.</param>
|
||||
/// <param name="shouldSaveMetadataInMediaDirectories">Optional. Whether metadata should be saved in the media directories.</param>
|
||||
/// <param name="shouldSkipUnchangedDirectoriesDuringScan">Optional. Whether unchanged directories should be skipped during scan.</param>
|
||||
/// <param name="createdOnUtc">Optional. The date and time when the library was created.</param>
|
||||
@@ -44,7 +44,7 @@ public class LibraryResponseFixture
|
||||
string? coverImage = null,
|
||||
bool? isEnabled = null,
|
||||
bool? isLocked = null,
|
||||
bool? downloadMetadataFromWeb = null,
|
||||
bool? canDownloadMetadataFromWeb = null,
|
||||
bool? shouldSaveMetadataInMediaDirectories = null,
|
||||
bool? shouldSkipUnchangedDirectoriesDuringScan = null,
|
||||
DateTime? createdOnUtc = null,
|
||||
@@ -59,7 +59,7 @@ public class LibraryResponseFixture
|
||||
coverImage,
|
||||
isEnabled ?? _faker.Random.Bool(),
|
||||
isLocked ?? _faker.Random.Bool(),
|
||||
downloadMetadataFromWeb ?? _faker.Random.Bool(),
|
||||
canDownloadMetadataFromWeb ?? _faker.Random.Bool(),
|
||||
shouldSaveMetadataInMediaDirectories ?? _faker.Random.Bool(),
|
||||
shouldSkipUnchangedDirectoriesDuringScan ?? _faker.Random.Bool(),
|
||||
createdOnUtc ?? _faker.Date.Past().ToUniversalTime(),
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.Plugins;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="LibraryMetadataProviderResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibraryMetadataProviderResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="LibraryMetadataProviderResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="pluginId">Optional. The Id of the plugin providing the metadata.</param>
|
||||
/// <param name="name">Optional. The display name of the metadata provider.</param>
|
||||
/// <param name="isEnabled">Optional. Whether the metadata provider is enabled for the media library.</param>
|
||||
/// <param name="rank">Optional. The rank of the metadata provider.</param>
|
||||
/// <returns>The created <see cref="LibraryMetadataProviderResponse"/>.</returns>
|
||||
public LibraryMetadataProviderResponse Create(
|
||||
Guid? pluginId = null,
|
||||
string? name = null,
|
||||
bool? isEnabled = null,
|
||||
int? rank = null)
|
||||
{
|
||||
return new LibraryMetadataProviderResponse(
|
||||
pluginId ?? Guid.NewGuid(),
|
||||
name ?? _faker.Company.CompanyName(),
|
||||
isEnabled ?? _faker.Random.Bool(),
|
||||
rank ?? _faker.Random.Int(1, 100));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="LibraryMetadataProviderResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<LibraryMetadataProviderResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Bogus;
|
||||
using Lumina.Contracts.Responses.UsersManagement.Settings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Contracts.Fixtures.Core.Responses.UsersManagement.Settings;
|
||||
|
||||
/// <summary>
|
||||
/// Fixture class for the <see cref="UserSettingsResponse"/> record.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UserSettingsResponseFixture
|
||||
{
|
||||
private readonly Faker _faker = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a random valid <see cref="UserSettingsResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="userId">Optional. The Id of the user that owns these settings.</param>
|
||||
/// <param name="isPaginationEnabled">Optional. Whether pagination is enabled for the user.</param>
|
||||
/// <param name="itemsPerPage">Optional. The number of library items displayed per page when pagination is enabled.</param>
|
||||
/// <param name="shouldIgnoreThePrefixForAlphaPicker">Optional. Whether the "The" prefix is ignored by the alpha picker.</param>
|
||||
/// <param name="isThemeCachingEnabled">Optional. Whether the theme data served to this user is cached.</param>
|
||||
/// <param name="shouldAggregateMetadataWhenMissing">Optional. Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing.</param>
|
||||
/// <returns>The created <see cref="UserSettingsResponse"/>.</returns>
|
||||
public UserSettingsResponse Create(
|
||||
Guid? userId = null,
|
||||
bool? isPaginationEnabled = null,
|
||||
int? itemsPerPage = null,
|
||||
bool? shouldIgnoreThePrefixForAlphaPicker = null,
|
||||
bool? isThemeCachingEnabled = null,
|
||||
bool? shouldAggregateMetadataWhenMissing = null)
|
||||
{
|
||||
return new UserSettingsResponse(
|
||||
userId ?? Guid.NewGuid(),
|
||||
isPaginationEnabled ?? _faker.Random.Bool(),
|
||||
itemsPerPage ?? _faker.Random.Int(1, 100),
|
||||
shouldIgnoreThePrefixForAlphaPicker ?? _faker.Random.Bool(),
|
||||
isThemeCachingEnabled ?? _faker.Random.Bool(),
|
||||
shouldAggregateMetadataWhenMissing ?? _faker.Random.Bool());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list of <see cref="UserSettingsResponse"/>.
|
||||
/// </summary>
|
||||
/// <param name="count">The number of elements to create.</param>
|
||||
/// <returns>The created list.</returns>
|
||||
public List<UserSettingsResponse> CreateMany(int count = 3)
|
||||
{
|
||||
return [.. Enumerable.Range(0, count).Select(_ => Create())];
|
||||
}
|
||||
}
|
||||
Loaded 100 of 168 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user