mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 06:11:10 +00:00
Adds the should aggregate artwork when missing setting to the user settings, configuration, and validation
This commit is contained in:
1 parent
6b5e731546
commit
e139a7bb00
21 files changed
+97
-43
No files matched your search
+5
@@ -26,4 +26,9 @@ public class MediaSettingsDto
|
||||
/// Gets or sets the directory where the media item files are stored.
|
||||
/// </summary>
|
||||
public required string BooksDirectory { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the directory where the music library item files are stored.
|
||||
/// </summary>
|
||||
public required string MusicDirectory { get; init; }
|
||||
}
|
||||
+1
@@ -23,6 +23,7 @@ public static class UpdateUserSettingsRequestMapping
|
||||
request.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
request.IsThemeCachingEnabled,
|
||||
request.ShouldAggregateMetadataWhenMissing,
|
||||
request.ShouldAggregateArtworkWhenMissing,
|
||||
request.ShouldRenderPdfAsImages,
|
||||
request.ShouldPreserveBookStyles
|
||||
);
|
||||
|
||||
+2
@@ -31,6 +31,7 @@ public static class UserSettingsEntityMapping
|
||||
repositoryEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
repositoryEntity.IsThemeCachingEnabled,
|
||||
repositoryEntity.ShouldAggregateMetadataWhenMissing,
|
||||
repositoryEntity.ShouldAggregateArtworkWhenMissing,
|
||||
repositoryEntity.ShouldRenderPdfAsImages,
|
||||
repositoryEntity.ShouldPreserveBookStyles
|
||||
);
|
||||
@@ -50,6 +51,7 @@ public static class UserSettingsEntityMapping
|
||||
repositoryEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
repositoryEntity.IsThemeCachingEnabled,
|
||||
repositoryEntity.ShouldAggregateMetadataWhenMissing,
|
||||
repositoryEntity.ShouldAggregateArtworkWhenMissing,
|
||||
repositoryEntity.ShouldRenderPdfAsImages,
|
||||
repositoryEntity.ShouldPreserveBookStyles
|
||||
);
|
||||
|
||||
@@ -27,6 +27,7 @@ public static class UserSettingsMapping
|
||||
ShouldIgnoreThePrefixForAlphaPicker = domainEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
IsThemeCachingEnabled = domainEntity.IsThemeCachingEnabled,
|
||||
ShouldAggregateMetadataWhenMissing = domainEntity.ShouldAggregateMetadataWhenMissing,
|
||||
ShouldAggregateArtworkWhenMissing = domainEntity.ShouldAggregateArtworkWhenMissing,
|
||||
ShouldRenderPdfAsImages = domainEntity.ShouldRenderPdfAsImages,
|
||||
ShouldPreserveBookStyles = domainEntity.ShouldPreserveBookStyles
|
||||
};
|
||||
@@ -46,6 +47,7 @@ public static class UserSettingsMapping
|
||||
domainEntity.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
domainEntity.IsThemeCachingEnabled,
|
||||
domainEntity.ShouldAggregateMetadataWhenMissing,
|
||||
domainEntity.ShouldAggregateArtworkWhenMissing,
|
||||
domainEntity.ShouldRenderPdfAsImages,
|
||||
domainEntity.ShouldPreserveBookStyles
|
||||
);
|
||||
|
||||
+2
@@ -12,6 +12,7 @@ namespace Lumina.Application.Core.UsersManagement.Settings.Commands.UpdateUserSe
|
||||
/// <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>
|
||||
/// <param name="ShouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
|
||||
/// <param name="ShouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
||||
/// <param name="ShouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
||||
public record UpdateUserSettingsCommand(
|
||||
@@ -20,6 +21,7 @@ public record UpdateUserSettingsCommand(
|
||||
bool ShouldIgnoreThePrefixForAlphaPicker,
|
||||
bool IsThemeCachingEnabled,
|
||||
bool ShouldAggregateMetadataWhenMissing,
|
||||
bool ShouldAggregateArtworkWhenMissing,
|
||||
bool ShouldRenderPdfAsImages,
|
||||
bool ShouldPreserveBookStyles
|
||||
) : ICommand;
|
||||
+2
@@ -74,6 +74,7 @@ public class UpdateUserSettingsCommandHandler : ICommandHandler<UpdateUserSettin
|
||||
command.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
command.IsThemeCachingEnabled,
|
||||
command.ShouldAggregateMetadataWhenMissing,
|
||||
command.ShouldAggregateArtworkWhenMissing,
|
||||
command.ShouldRenderPdfAsImages,
|
||||
command.ShouldPreserveBookStyles);
|
||||
if (createSettingsResult.IsFailure)
|
||||
@@ -96,6 +97,7 @@ public class UpdateUserSettingsCommandHandler : ICommandHandler<UpdateUserSettin
|
||||
command.ShouldIgnoreThePrefixForAlphaPicker,
|
||||
command.IsThemeCachingEnabled,
|
||||
command.ShouldAggregateMetadataWhenMissing,
|
||||
command.ShouldAggregateArtworkWhenMissing,
|
||||
command.ShouldRenderPdfAsImages,
|
||||
command.ShouldPreserveBookStyles);
|
||||
if (updateSettingsResult.IsFailure)
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Lumina.Contracts.Requests.UsersManagement.Settings;
|
||||
/// <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>
|
||||
/// <param name="ShouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not. Required.</param>
|
||||
/// <param name="ShouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not. Required.</param>
|
||||
/// <param name="ShouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not. Required.</param>
|
||||
[DebuggerDisplay("IsPaginationEnabled: {IsPaginationEnabled}; ItemsPerPage: {ItemsPerPage}")]
|
||||
@@ -21,6 +22,7 @@ public sealed record UpdateUserSettingsRequest(
|
||||
bool ShouldIgnoreThePrefixForAlphaPicker,
|
||||
bool IsThemeCachingEnabled,
|
||||
bool ShouldAggregateMetadataWhenMissing,
|
||||
bool ShouldAggregateArtworkWhenMissing,
|
||||
bool ShouldRenderPdfAsImages,
|
||||
bool ShouldPreserveBookStyles
|
||||
);
|
||||
@@ -14,6 +14,7 @@ namespace Lumina.Contracts.Responses.UsersManagement.Settings;
|
||||
/// <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>
|
||||
/// <param name="ShouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
|
||||
/// <param name="ShouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
||||
/// <param name="ShouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
||||
[DebuggerDisplay("UserId: {UserId}")]
|
||||
@@ -24,6 +25,7 @@ public sealed record UserSettingsResponse(
|
||||
bool ShouldIgnoreThePrefixForAlphaPicker,
|
||||
bool IsThemeCachingEnabled,
|
||||
bool ShouldAggregateMetadataWhenMissing,
|
||||
bool ShouldAggregateArtworkWhenMissing,
|
||||
bool ShouldRenderPdfAsImages,
|
||||
bool ShouldPreserveBookStyles
|
||||
);
|
||||
+20
-1
@@ -20,6 +20,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
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;
|
||||
private const bool DEFAULT_AGGREGATE_ARTWORK_WHEN_MISSING = false;
|
||||
private const bool DEFAULT_SHOULD_RENDER_PDF_AS_IMAGES = false;
|
||||
private const bool DEFAULT_SHOULD_PRESERVE_BOOK_STYLES = true;
|
||||
|
||||
@@ -53,6 +54,11 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// </summary>
|
||||
public bool ShouldAggregateMetadataWhenMissing { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.
|
||||
/// </summary>
|
||||
public bool ShouldAggregateArtworkWhenMissing { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether PDF books are rendered as page images for the user, or not. Rendering PDFs as images preserves the original
|
||||
/// layout, but the pages are not selectable or searchable, unlike their text layer.
|
||||
@@ -76,6 +82,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// <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>
|
||||
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
|
||||
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
||||
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
||||
private UserSettings(
|
||||
@@ -86,6 +93,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
bool shouldIgnoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled,
|
||||
bool shouldAggregateMetadataWhenMissing,
|
||||
bool shouldAggregateArtworkWhenMissing,
|
||||
bool shouldRenderPdfAsImages,
|
||||
bool shouldPreserveBookStyles) : base(id)
|
||||
{
|
||||
@@ -95,6 +103,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker;
|
||||
IsThemeCachingEnabled = isThemeCachingEnabled;
|
||||
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing;
|
||||
ShouldAggregateArtworkWhenMissing = shouldAggregateArtworkWhenMissing;
|
||||
ShouldRenderPdfAsImages = shouldRenderPdfAsImages;
|
||||
ShouldPreserveBookStyles = shouldPreserveBookStyles;
|
||||
}
|
||||
@@ -114,6 +123,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER,
|
||||
DEFAULT_IS_THEME_CACHING_ENABLED,
|
||||
DEFAULT_AGGREGATE_METADATA_WHEN_MISSING,
|
||||
DEFAULT_AGGREGATE_ARTWORK_WHEN_MISSING,
|
||||
DEFAULT_SHOULD_RENDER_PDF_AS_IMAGES,
|
||||
DEFAULT_SHOULD_PRESERVE_BOOK_STYLES
|
||||
);
|
||||
@@ -135,6 +145,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
DEFAULT_IGNORE_THE_PREFIX_FOR_ALPHA_PICKER,
|
||||
DEFAULT_IS_THEME_CACHING_ENABLED,
|
||||
DEFAULT_AGGREGATE_METADATA_WHEN_MISSING,
|
||||
DEFAULT_AGGREGATE_ARTWORK_WHEN_MISSING,
|
||||
DEFAULT_SHOULD_RENDER_PDF_AS_IMAGES,
|
||||
DEFAULT_SHOULD_PRESERVE_BOOK_STYLES
|
||||
);
|
||||
@@ -149,6 +160,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// <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>
|
||||
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
|
||||
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
||||
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
||||
/// <returns>
|
||||
@@ -161,6 +173,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
bool shouldIgnoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled,
|
||||
bool shouldAggregateMetadataWhenMissing,
|
||||
bool shouldAggregateArtworkWhenMissing,
|
||||
bool shouldRenderPdfAsImages,
|
||||
bool shouldPreserveBookStyles)
|
||||
{
|
||||
@@ -175,6 +188,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
shouldIgnoreThePrefixForAlphaPicker,
|
||||
isThemeCachingEnabled,
|
||||
shouldAggregateMetadataWhenMissing,
|
||||
shouldAggregateArtworkWhenMissing,
|
||||
shouldRenderPdfAsImages,
|
||||
shouldPreserveBookStyles);
|
||||
}
|
||||
@@ -189,6 +203,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// <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>
|
||||
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
|
||||
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
||||
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
||||
/// <returns>
|
||||
@@ -202,13 +217,14 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
bool shouldIgnoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled,
|
||||
bool shouldAggregateMetadataWhenMissing,
|
||||
bool shouldAggregateArtworkWhenMissing,
|
||||
bool shouldRenderPdfAsImages,
|
||||
bool shouldPreserveBookStyles)
|
||||
{
|
||||
if (itemsPerPage <= 0)
|
||||
return Errors.UserSettings.ItemsPerPageMustBeGreaterThanZero;
|
||||
|
||||
return new UserSettings(id, userId, isPaginationEnabled, itemsPerPage, shouldIgnoreThePrefixForAlphaPicker, isThemeCachingEnabled, shouldAggregateMetadataWhenMissing, shouldRenderPdfAsImages, shouldPreserveBookStyles);
|
||||
return new UserSettings(id, userId, isPaginationEnabled, itemsPerPage, shouldIgnoreThePrefixForAlphaPicker, isThemeCachingEnabled, shouldAggregateMetadataWhenMissing, shouldAggregateArtworkWhenMissing, shouldRenderPdfAsImages, shouldPreserveBookStyles);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -219,6 +235,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
/// <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>
|
||||
/// <param name="shouldAggregateArtworkWhenMissing">Whether the artwork of the media library items is aggregated from multiple providers, when it is missing, or not.</param>
|
||||
/// <param name="shouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
|
||||
/// <param name="shouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> representing either a successful update, or an error.</returns>
|
||||
@@ -228,6 +245,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
bool shouldIgnoreThePrefixForAlphaPicker,
|
||||
bool isThemeCachingEnabled,
|
||||
bool shouldAggregateMetadataWhenMissing,
|
||||
bool shouldAggregateArtworkWhenMissing,
|
||||
bool shouldRenderPdfAsImages,
|
||||
bool shouldPreserveBookStyles)
|
||||
{
|
||||
@@ -239,6 +257,7 @@ public class UserSettings : AggregateRoot<UserSettingsId>
|
||||
ShouldIgnoreThePrefixForAlphaPicker = shouldIgnoreThePrefixForAlphaPicker;
|
||||
IsThemeCachingEnabled = isThemeCachingEnabled;
|
||||
ShouldAggregateMetadataWhenMissing = shouldAggregateMetadataWhenMissing;
|
||||
ShouldAggregateArtworkWhenMissing = shouldAggregateArtworkWhenMissing;
|
||||
ShouldRenderPdfAsImages = shouldRenderPdfAsImages;
|
||||
ShouldPreserveBookStyles = shouldPreserveBookStyles;
|
||||
return Result.Updated;
|
||||
|
||||
@@ -15,6 +15,7 @@ public static partial class Errors
|
||||
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 MediaMusicDirectoryCannotBeEmpty => Error.Validation(description: nameof(MediaMusicDirectoryCannotBeEmpty));
|
||||
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));
|
||||
|
||||
@@ -27,5 +27,9 @@ public class MediaSettingsDtoValidator : AbstractValidator<MediaSettingsDto>
|
||||
RuleFor(settings => settings.BooksDirectory)
|
||||
.NotEmpty()
|
||||
.WithError(Errors.Errors.Configuration.MediaBooksDirectoryCannotBeEmpty);
|
||||
|
||||
RuleFor(settings => settings.MusicDirectory)
|
||||
.NotEmpty()
|
||||
.WithError(Errors.Errors.Configuration.MediaMusicDirectoryCannotBeEmpty);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,8 @@
|
||||
"MediaSettings": {
|
||||
"RootDirectory": "media",
|
||||
"LibrariesDirectory": "libraries",
|
||||
"BooksDirectory": "books"
|
||||
"BooksDirectory": "books",
|
||||
"MusicDirectory": "music"
|
||||
},
|
||||
"PluginsSettings": {
|
||||
"Directory": "plugins"
|
||||
|
||||
Reference in new issue
Block a user