Skip to content

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.

Restricted Profiles (#1581)

Joe Milazzo442af965c654
diff --git a/API.Tests/Services/ReadingListServiceTests.cs b/API.Tests/Services/ReadingListServiceTests.cs
index 4df8fb688..200900bb1 100644
--- a/API.Tests/Services/ReadingListServiceTests.cs
+++ b/API.Tests/Services/ReadingListServiceTests.cs
@@ -4,10 +4,13 @@ using System.IO.Abstractions.TestingHelpers;
using System.Linq;
using System.Threading.Tasks;
using API.Data;
+using API.Data.Repositories;
+using API.DTOs.ReadingLists;
using API.Entities;
using API.Entities.Enums;
using API.Helpers;
using API.Services;
+using API.SignalR;
using AutoMapper;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
@@ -79,9 +82,10 @@ public class ReadingListServiceTests
private async Task ResetDb()
{
- _context.Series.RemoveRange(_context.Series.ToList());
-
- await _context.SaveChangesAsync();
+ _context.AppUser.RemoveRange(_context.AppUser);
+ _context.Series.RemoveRange(_context.Series);
+ _context.ReadingList.RemoveRange(_context.ReadingList);
+ await _unitOfWork.CommitAsync();
}
private static MockFileSystem CreateFileSystem()
@@ -99,11 +103,373 @@ public class ReadingListServiceTests
#endregion
+ #region UpdateReadingListItemPosition
+
+ [Fact]
+ public async Task UpdateReadingListItemPosition_MoveLastToFirst_TwoItemsShouldShift()
+ {
+ await ResetDb();
+ _context.AppUser.Add(new AppUser()
+ {
+ UserName = "majora2007",
+ ReadingLists = new List<ReadingList>(),
+ Libraries = new List<Library>()
+ {
+ new Library()
+ {
+ Name = "Test LIb",
+ Type = LibraryType.Book,
+ Series = new List<Series>()
+ {
+ new Series()
+ {
+ Name = "Test",
+ Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>()),
+ Volumes = new List<Volume>()
+ {
+ new Volume()
+ {
+ Name = "0",
+ Chapters = new List<Chapter>()
+ {
+ new Chapter()
+ {
+ Number = "1",
+ AgeRating = AgeRating.Everyone,
+ },
+ new Chapter()
+ {
+ Number = "2",
+ AgeRating = AgeRating.X18Plus
+ },
+ new Chapter()
+ {
+ Number = "3",
+ AgeRating = AgeRating.X18Plus
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ }
+ });
+
+ await _context.SaveChangesAsync();
+
+ var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.ReadingLists);
+ var readingList = new ReadingList();
+ user.ReadingLists = new List<ReadingList>()
+ {
+ readingList
+ };
+
+ await _readingListService.AddChaptersToReadingList(1, new List<int>() {1, 2, 3}, readingList);
+ await _unitOfWork.CommitAsync();
+ Assert.Equal(3, readingList.Items.Count);
+
+ await _readingListService.UpdateReadingListItemPosition(new UpdateReadingListPosition()
+ {
+ FromPosition = 2, ToPosition = 0, ReadingListId = 1, ReadingListItemId = 3
+ });
+
+
+ Assert.Equal(3, readingList.Items.Count);
+ Assert.Equal(0, readingList.Items.Single(i => i.ChapterId == 3).Order);
+ Assert.Equal(1, readingList.Items.Single(i => i.ChapterId == 1).Order);
+ Assert.Equal(2, readingList.Items.Single(i => i.ChapterId == 2).Order);
+ }
+
+
+ #endregion
+
+ #region DeleteReadingListItem
+
+ [Fact]
+ public async Task DeleteReadingListItem_DeleteFirstItem_SecondShouldBecomeFirst()
+ {
+ await ResetDb();
+ _context.AppUser.Add(new AppUser()
+ {
+ UserName = "majora2007",
+ ReadingLists = new List<ReadingList>(),
+ Libraries = new List<Library>()
+ {
+ new Library()
+ {
+ Name = "Test LIb",
+ Type = LibraryType.Book,
+ Series = new List<Series>()
+ {
+ new Series()
+ {
+ Name = "Test",
+ Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>()),
+ Volumes = new List<Volume>()
+ {
+ new Volume()
+ {
+ Name = "0",
+ Chapters = new List<Chapter>()
+ {
+ new Chapter()
+ {
+ Number = "1",
+ AgeRating = AgeRating.Everyone
+ },
+ new Chapter()
+ {
+ Number = "2",
+ AgeRating = AgeRating.X18Plus
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ }
+ });
+
+ await _context.SaveChangesAsync();
+
+ var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.ReadingLists);
+ var readingList = new ReadingList();
+ user.ReadingLists = new List<ReadingList>()
+ {
+ readingList
+ };
+
+ await _readingListService.AddChaptersToReadingList(1, new List<int>() {1, 2}, readingList);
+ await _unitOfWork.CommitAsync();
+ Assert.Equal(2, readingList.Items.Count);
+
+ await _readingListService.DeleteReadingListItem(new UpdateReadingListPosition()
+ {
+ ReadingListId = 1, ReadingListItemId = 1
+ });
+
+ Assert.Equal(1, readingList.Items.Count);
+ Assert.Equal(2, readingList.Items.First().ChapterId);
+ }
+
+ #endregion
#region RemoveFullyReadItems
- // TODO: Implement all methods here
+ [Fact]
+ public async Task RemoveFullyReadItems_RemovesAllFullyReadItems()
+ {
+ await ResetDb();
+ _context.AppUser.Add(new AppUser()
+ {
+ UserName = "majora2007",
+ ReadingLists = new List<ReadingList>(),
+ Libraries = new List<Library>()
+ {
+ new Library()
+ {
+ Name = "Test LIb",
+ Type = LibraryType.Book,
+ Series = new List<Series>()
+ {
+ new Series()
+ {
+ Name = "Test",
+ Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>()),
+ Volumes = new List<Volume>()
+ {
+ new Volume()
+ {
+ Name = "0",
+ Chapters = new List<Chapter>()
+ {
+ new Chapter()
+ {
+ Number = "1",
+ AgeRating = AgeRating.Everyone,
+ Pages = 1
+ },
+ new Chapter()
+ {
+ Number = "2",
+ AgeRating = AgeRating.X18Plus,
+ Pages = 1
+ },
+ new Chapter()
+ {
+ Number = "3",
+ AgeRating = AgeRating.X18Plus,
+ Pages = 1
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ }
+ });
+
+ await _context.SaveChangesAsync();
+
+ var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.ReadingLists | AppUserIncludes.Progress);
+ var readingList = new ReadingList();
+ user.ReadingLists = new List<ReadingList>()
+ {
+ readingList
+ };
+
+ await _readingListService.AddChaptersToReadingList(1, new List<int>() {1, 2, 3}, readingList);
+ await _unitOfWork.CommitAsync();
+ Assert.Equal(3, readingList.Items.Count);
+
+ var readerService = new ReaderService(_unitOfWork, Substitute.For<ILogger<ReaderService>>(),
+ Substitute.For<IEventHub>());
+ // Mark 2 as fully read
+ await readerService.MarkChaptersAsRead(user, 1,
+ await _unitOfWork.ChapterRepository.GetChaptersByIdsAsync(new List<int>() {2}));
+ await _unitOfWork.CommitAsync();
+
+ await _readingListService.RemoveFullyReadItems(1, user);
+
+
+ Assert.Equal(2, readingList.Items.Count);
+ Assert.DoesNotContain(readingList.Items, i => i.Id == 2);
+ }
+
#endregion
+
+ #region CalculateAgeRating
+
+ [Fact]
+ public async Task CalculateAgeRating_ShouldUpdateToUnknown_IfNoneSet()
+ {
+ await ResetDb();
+ _context.AppUser.Add(new AppUser()
+ {
+ UserName = "majora2007",
+ ReadingLists = new List<ReadingList>(),
+ Libraries = new List<Library>()
+ {
+ new Library()
+ {
+ Name = "Test LIb",
+ Type = LibraryType.Book,
+ Series = new List<Series>()
+ {
+ new Series()
+ {
+ Name = "Test",
+ Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>()),
+ Volumes = new List<Volume>()
+ {
+ new Volume()
+ {
+ Name = "0",
+ Chapters = new List<Chapter>()
+ {
+ new Chapter()
+ {
+ Number = "1",
+ },
+ new Chapter()
+ {
+ Number = "2",
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ }
+ });
+
+ await _context.SaveChangesAsync();
+
+ var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.ReadingLists);
+ var readingList = new ReadingList();
+ user.ReadingLists = new List<ReadingList>()
+ {
+ readingList
+ };
+
+ await _readingListService.AddChaptersToReadingList(1, new List<int>() {1, 2}, readingList);
+
+
+ _unitOfWork.UserRepository.Update(user);
+ await _unitOfWork.CommitAsync();
+
+ await _readingListService.CalculateReadingListAgeRating(readingList);
+ Assert.Equal(AgeRating.Unknown, readingList.AgeRating);
+ }
+
+ [Fact]
+ public async Task CalculateAgeRating_ShouldUpdateToMax()
+ {
+ await ResetDb();
+ _context.AppUser.Add(new AppUser()
+ {
+ UserName = "majora2007",
+ ReadingLists = new List<ReadingList>(),
+ Libraries = new List<Library>()
+ {
+ new Library()
+ {
+ Name = "Test LIb",
+ Type = LibraryType.Book,
+ Series = new List<Series>()
+ {
+ new Series()
+ {
+ Name = "Test",
+ Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>()),
+ Volumes = new List<Volume>()
+ {
+ new Volume()
+ {
+ Name = "0",
+ Chapters = new List<Chapter>()
+ {
+ new Chapter()
+ {
+ Number = "1",
+ },
+ new Chapter()
+ {
+ Number = "2",
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ }
+ });
+
+ await _context.SaveChangesAsync();
+
+ var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.ReadingLists);
+ var readingList = new ReadingList();
+ user.ReadingLists = new List<ReadingList>()
+ {
+ readingList
+ };
+
+ await _readingListService.AddChaptersToReadingList(1, new List<int>() {1, 2}, readingList);
+
+
+ _unitOfWork.UserRepository.Update(user);
+ await _unitOfWork.CommitAsync();
+
+ await _readingListService.CalculateReadingListAgeRating(readingList);
+ Assert.Equal(AgeRating.Unknown, readingList.AgeRating);
+ }
+
+ #endregion
}
diff --git a/API/Constants/PolicyConstants.cs b/API/Constants/PolicyConstants.cs
index 403fdd026..546ad4158 100644
--- a/API/Constants/PolicyConstants.cs
+++ b/API/Constants/PolicyConstants.cs
@@ -27,7 +27,11 @@ public static class PolicyConstants
/// Used to give a user ability to bookmark files on the server
/// </summary>
public const string BookmarkRole = "Bookmark";
+ /// <summary>
+ /// Used to give a user ability to Change Restrictions on their account
+ /// </summary>
+ public const string ChangeRestrictionRole = "Change Restriction";
public static readonly ImmutableArray<string> ValidRoles =
- ImmutableArray.Create(AdminRole, PlebRole, DownloadRole, ChangePasswordRole, BookmarkRole);
+ ImmutableArray.Create(AdminRole, PlebRole, DownloadRole, ChangePasswordRole, BookmarkRole, ChangeRestrictionRole);
}
diff --git a/API/Controllers/AccountController.cs b/API/Controllers/AccountController.cs
index 660f962e6..fc72a5111 100644
--- a/API/Controllers/AccountController.cs
+++ b/API/Controllers/AccountController.cs
@@ -12,7 +12,6 @@ using API.DTOs.Account;
using API.DTOs.Email;
using API.Entities;
using API.Entities.Enums;
-using API.Entities.Enums.UserPreferences;
using API.Errors;
using API.Extensions;
using API.Services;
@@ -358,6 +357,34 @@ public class AccountController : BaseApiController
return Ok();
}
+ [HttpPost("update/age-restriction")]
+ public async Task<ActionResult> UpdateAgeRestriction(UpdateAgeRestrictionDto dto)
+ {
+ var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
+ if (user == null) return Unauthorized("You do not have permission");
+ if (dto == null) return BadRequest("Invalid payload");
+
+ var isAdmin = await _unitOfWork.UserRepository.IsUserAdminAsync(user);
+
+ user.AgeRestriction = isAdmin ? AgeRating.NotApplicable : dto.AgeRestriction;
+ _unitOfWork.UserRepository.Update(user);
+
+ if (!_unitOfWork.HasChanges()) return Ok();
+ try
+ {
+ await _unitOfWork.CommitAsync();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "There was an error updating the age restriction");
+ return BadRequest("There was an error updating the age restriction");
+ }
+
+ await _eventHub.SendMessageToAsync(MessageFactory.UserUpdate, MessageFactory.UserUpdateEvent(user.Id, user.UserName), user.Id);
+
+ return Ok();
+ }
+
/// <summary>
/// Update the user account. This can only affect Username, Email (will require confirming), Roles, and Library access.
/// </summary>
@@ -428,6 +455,9 @@ public class AccountController : BaseApiController
lib.AppUsers.Add(user);
}
+ user.AgeRestriction = hasAdminRole ? AgeRating.NotApplicable : dto.AgeRestriction;
+ _unitOfWork.UserRepository.Update(user);
+
if (!_unitOfWork.HasChanges() || await _unitOfWork.CommitAsync())
{
await _eventHub.SendMessageToAsync(MessageFactory.UserUpdate, MessageFactory.UserUpdateEvent(user.Id, user.UserName), user.Id);
@@ -540,6 +570,8 @@ public class AccountController : BaseApiController
lib.AppUsers.Add(user);
}
+ user.AgeRestriction = hasAdminRole ? AgeRating.NotApplicable : dto.AgeRestriction;
+
var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);
if (string.IsNullOrEmpty(token))
{
diff --git a/API/Controllers/CollectionController.cs b/API/Controllers/CollectionController.cs
index b216ed6c7..33bde22b6 100644
--- a/API/Controllers/CollectionController.cs
+++ b/API/Controllers/CollectionController.cs
@@ -41,7 +41,8 @@ public class CollectionController : BaseApiController
{
return await _unitOfWork.CollectionTagRepository.GetAllTagDtosAsync();
}
- return await _unitOfWork.CollectionTagRepository.GetAllPromotedTagDtosAsync();
+
+ return await _unitOfWork.CollectionTagRepository.GetAllPromotedTagDtosAsync(user.Id);
}
/// <summary>
@@ -56,9 +57,10 @@ public class CollectionController : BaseApiController
{
queryString ??= "";
queryString = queryString.Replace(@"%", string.Empty);
- if (queryString.Length == 0) return await _unitOfWork.CollectionTagRepository.GetAllTagDtosAsync();
+ if (queryString.Length == 0) return await GetAllTags();
- return await _unitOfWork.CollectionTagRepository.SearchTagDtosAsync(queryString);
+ var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
+ return await _unitOfWork.CollectionTagRepository.SearchTagDtosAsync(queryString, user.Id);
}
/// <summary>
diff --git a/API/Controllers/LibraryController.cs b/API/Controllers/LibraryController.cs
index 56ab5a41e..98377c5fd 100644
--- a/API/Controllers/LibraryController.cs
+++ b/API/Controllers/LibraryController.cs
@@ -319,23 +319,6 @@ public class LibraryController : BaseApiController
}
- [HttpGet("search")]
- public async Task<ActionResult<SearchResultGroupDto>> Search(string queryString)
- {
- queryString = Uri.UnescapeDataString(queryString).Trim().Replace(@"%", string.Empty).Replace(":", string.Empty);
-
- var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
- // Get libraries user has access to
- var libraries = (await _unitOfWork.LibraryRepository.GetLibrariesForUserIdAsync(user.Id)).ToList();
-
- if (!libraries.Any()) return BadRequest("User does not have access to any libraries");
- if (!libraries.Any()) return BadRequest("User does not have access to any libraries");
- var isAdmin = await _unitOfWork.UserRepository.IsUserAdminAsync(user);
-
- var series = await _unitOfWork.SeriesRepository.SearchSeries(user.Id, isAdmin, libraries.Select(l => l.Id).ToArray(), queryString);
-
- return Ok(series);
- }
[HttpGet("type")]
public async Task<ActionResult<LibraryType>> GetLibraryType(int libraryId)
diff --git a/API/Controllers/MetadataController.cs b/API/Controllers/MetadataController.cs
index ffc0afa64..9c659637f 100644
--- a/API/Controllers/MetadataController.cs
+++ b/API/Controllers/MetadataController.cs
@@ -76,7 +76,9 @@ public class MetadataController : BaseApiController
/// Fetches all age ratings from the instance
/// </summary>
/// <param name="libraryIds">String separated libraryIds or null for all ratings</param>
+ /// <remarks>This API is cached for 1 hour, varying by libraryIds</remarks>
/// <returns></returns>
+ [ResponseCache(Duration = 60 * 5, Location = ResponseCacheLocation.Any, VaryByQueryKeys = new [] {"libraryIds"})]
[HttpGet("age-ratings")]
public async Task<ActionResult<IList<AgeRatingDto>>> GetAllAgeRatings(string? libraryIds)
{
@@ -90,14 +92,16 @@ public class MetadataController : BaseApiController
{
Title = t.ToDescription(),
Value = t
- }));
+ }).Where(r => r.Value > AgeRating.NotApplicable));
}
/// <summary>
/// Fetches all publication status' from the instance
/// </summary>
/// <param name="libraryIds">String separated libraryIds or null for all publication status</param>
+ /// <remarks>This API is cached for 1 hour, varying by libraryIds</remarks>
/// <returns></returns>
+ [ResponseCache(Duration = 60 * 5, Location = ResponseCacheLocation.Any, VaryByQueryKeys = new [] {"libraryIds"})]
[HttpGet("publication-status")]
public ActionResult<IList<AgeRatingDto>> GetAllPublicationStatus(string? libraryIds)
{
diff --git a/API/Controllers/OPDSController.cs b/API/Controllers/OPDSController.cs
index d254ff30e..c13a99079 100644
--- a/API/Controllers/OPDSController.cs
+++ b/API/Controllers/OPDSController.cs
@@ -196,8 +196,8 @@ public class OpdsController : BaseApiController
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(userId);
var isAdmin = await _unitOfWork.UserRepository.IsUserAdminAsync(user);
- IList<CollectionTagDto> tags = isAdmin ? (await _unitOfWork.CollectionTagRepository.GetAllTagDtosAsync()).ToList()
- : (await _unitOfWork.CollectionTagRepository.GetAllPromotedTagDtosAsync()).ToList();
+ IEnumerable<CollectionTagDto> tags = isAdmin ? (await _unitOfWork.CollectionTagRepository.GetAllTagDtosAsync())
+ : (await _unitOfWork.CollectionTagRepository.GetAllPromotedTagDtosAsync(userId));
var feed = CreateFeed("All Collections", $"{apiKey}/collections", apiKey);
@@ -239,7 +239,7 @@ public class OpdsController : BaseApiController
}
else
{
- tags = await _unitOfWork.CollectionTagRepository.GetAllPromotedTagDtosAsync();
+ tags = await _unitOfWork.CollectionTagRepository.GetAllPromotedTagDtosAsync(userId);
}
var tag = tags.SingleOrDefault(t => t.Id == collectionId);
diff --git a/API/Controllers/ReadingListController.cs b/API/Controllers/ReadingListController.cs
index b150bdc01..0e4970a3e 100644
--- a/API/Controllers/ReadingListController.cs
+++ b/API/Controllers/ReadingListController.cs
@@ -45,11 +45,11 @@ public class ReadingListController : BaseApiController
/// <summary>
/// Returns reading lists (paginated) for a given user.
/// </summary>
- /// <param name="includePromoted">Defaults to true</param>
+ /// <param name="includePromoted">Include Promoted Reading Lists along with user's Reading Lists. Defaults to true</param>
/// <param name="userParams">Pagination parameters</param>
/// <returns></returns>
[HttpPost("lists")]
- public async Task<ActionResult<IEnumerable<ReadingListDto>>> GetListsForUser([FromQuery] UserParams userParams, [FromQuery] bool includePromoted = true)
+ public async Task<ActionResult<IEnumerable<ReadingListDto>>> GetListsForUser([FromQuery] UserParams userParams, bool includePromoted = true)
{
var userId = await _unitOfWork.UserRepository.GetUserIdByUsernameAsync(User.GetUsername());
var items = await _unitOfWork.ReadingListRepository.GetReadingListDtosForUserAsync(userId, includePromoted,
@@ -217,9 +217,15 @@ public class ReadingListController : BaseApiController
return BadRequest("You do not have permissions on this reading list or the list doesn't exist");
}
+ dto.Title = dto.Title.Trim();
if (!string.IsNullOrEmpty(dto.Title))
{
- readingList.Title = dto.Title; // Should I check if this is unique?
+ var hasExisting = user.ReadingLists.Any(l => l.Title.Equals(dto.Title));
+ if (hasExisting)
+ {
+ return BadRequest("A list of this name already exists");
+ }
+ readingList.Title = dto.Title;
readingList.NormalizedTitle = Services.Tasks.Scanner.Parser.Parser.Normalize(readingList.Title);
}
if (!string.IsNullOrEmpty(dto.Title))
diff --git a/API/Controllers/SearchController.cs b/API/Controllers/SearchController.cs
new file mode 100644
index 000000000..722a3b310
--- /dev/null
+++ b/API/Controllers/SearchController.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using API.Data;
+using API.DTOs;
+using API.DTOs.Search;
+using API.Extensions;
+using Microsoft.AspNetCore.Mvc;
+
+namespace API.Controllers;
+
+/// <summary>
+/// Responsible for the Search interface from the UI
+/// </summary>
+public class SearchController : BaseApiController
+{
+ private readonly IUnitOfWork _unitOfWork;
+
+ public SearchController(IUnitOfWork unitOfWork)
+ {
+ _unitOfWork = unitOfWork;
+ }
+
+ /// <summary>
+ /// Returns the series for the MangaFile id. If the user does not have access (shouldn't happen by the UI),
+ /// then null is returned
+ /// </summary>
+ /// <param name="mangaFileId"></param>
+ /// <returns></returns>
+ [HttpGet("series-for-mangafile")]
+ public async Task<ActionResult<SeriesDto>> GetSeriesForMangaFile(int mangaFileId)
+ {
+ var userId = await _unitOfWork.UserRepository.GetUserIdByUsernameAsync(User.GetUsername());
+ return Ok(await _unitOfWork.SeriesRepository.GetSeriesForMangaFile(mangaFileId, userId));
+ }
+
+ /// <summary>
+ /// Returns the series for the Chapter id. If the user does not have access (shouldn't happen by the UI),
+ /// then null is returned
+ /// </summary>
+ /// <param name="chapterId"></param>
+ /// <returns></returns>
+ [HttpGet("series-for-chapter")]
+ public async Task<ActionResult<SeriesDto>> GetSeriesForChapter(int chapterId)
+ {
+ var userId = await _unitOfWork.UserRepository.GetUserIdByUsernameAsync(User.GetUsername());
+ return Ok(await _unitOfWork.SeriesRepository.GetSeriesForChapter(chapterId, userId));
+ }
+
+ [HttpGet("search")]
+ public async Task<ActionResult<SearchResultGroupDto>> Search(string queryString)
+ {
+ queryString = Uri.UnescapeDataString(queryString).Trim().Replace(@"%", string.Empty).Replace(":", string.Empty);
+
+ var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
+ // Get libraries user has access to
+ var libraries = (await _unitOfWork.LibraryRepository.GetLibrariesForUserIdAsync(user.Id)).ToList();
+
+ if (!libraries.Any()) return BadRequest("User does not have access to any libraries");
+ if (!libraries.Any()) return BadRequest("User does not have access to any libraries");
+ var isAdmin = await _unitOfWork.UserRepository.IsUserAdminAsync(user);
+
+ var series = await _unitOfWork.SeriesRepository.SearchSeries(user.Id, isAdmin, libraries.Select(l => l.Id).ToArray(), queryString);
+
+ return Ok(series);
+ }
+}
diff --git a/API/Controllers/SeriesController.cs b/API/Controllers/SeriesController.cs
index 3b4c95bb0..2304170e3 100644
--- a/API/Controllers/SeriesController.cs
+++ b/API/Controllers/SeriesController.cs
@@ -363,10 +363,13 @@ public class SeriesController : BaseApiController
/// </summary>
/// <param name="ageRating"></param>
/// <returns></returns>
+ /// <remarks>This is cached for an hour</remarks>
+ [ResponseCache(Duration = 60 * 60, Location = ResponseCacheLocation.Any, VaryByQueryKeys = new [] {"ageRating"})]
[HttpGet("age-rating")]
public ActionResult<string> GetAgeRating(int ageRating)
{
var val = (AgeRating) ageRating;
+ if (val == AgeRating.NotApplicable) return "No Restriction";
return Ok(val.ToDescription());
}
@@ -385,31 +388,7 @@ public class SeriesController : BaseApiController
return await _seriesService.GetSeriesDetail(seriesId, userId);
}
- /// <summary>
- /// Returns the series for the MangaFile id. If the user does not have access (shouldn't happen by the UI),
- /// then null is returned
- /// </summary>
- /// <param name="mangaFileId"></param>
- /// <returns></returns>
- [HttpGet("series-for-mangafile")]
- public async Task<ActionResult<SeriesDto>> GetSeriesForMangaFile(int mangaFileId)
- {
- var userId = await _unitOfWork.UserRepository.GetUserIdByUsernameAsync(User.GetUsername());
- return Ok(await _unitOfWork.SeriesRepository.GetSeriesForMangaFile(mangaFileId, userId));
- }
- /// <summary>
- /// Returns the series for the Chapter id. If the user does not have access (shouldn't happen by the UI),
- /// then null is returned
- /// </summary>
- /// <param name="chapterId"></param>
- /// <returns></returns>
- [HttpGet("series-for-chapter")]
- public async Task<ActionResult<SeriesDto>> GetSeriesForChapter(int chapterId)
- {
- var userId = await _unitOfWork.UserRepository.GetUserIdByUsernameAsync(User.GetUsername());
- return Ok(await _unitOfWork.SeriesRepository.GetSeriesForChapter(chapterId, userId));
- }
/// <summary>
/// Fetches the related series for a given series
diff --git a/API/DTOs/Account/InviteUserDto.cs b/API/DTOs/Account/InviteUserDto.cs
index 9d0d9416d..86bed4476 100644
--- a/API/DTOs/Account/InviteUserDto.cs
+++ b/API/DTOs/Account/InviteUserDto.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+using API.Entities.Enums;
namespace API.DTOs.Account;
@@ -16,4 +17,8 @@ public class InviteUserDto
/// A list of libraries to grant access to
/// </summary>
public IList<int> Libraries { get; init; }
+ /// <summary>
+ /// An Age Rating which will limit the account to seeing everything equal to or below said rating.
+ /// </summary>
+ public AgeRating AgeRestriction { get; set; }
}
diff --git a/API/DTOs/Account/UpdateAgeRestrictionDto.cs b/API/DTOs/Account/UpdateAgeRestrictionDto.cs
new file mode 100644
index 000000000..edd1be9af
--- /dev/null
+++ b/API/DTOs/Account/UpdateAgeRestrictionDto.cs
@@ -0,0 +1,10 @@
+using System.ComponentModel.DataAnnotations;
+using API.Entities.Enums;
+
+namespace API.DTOs.Account;
+
+public class UpdateAgeRestrictionDto
+{
+ [Required]
+ public AgeRating AgeRestriction { get; set; }
+}
diff --git a/API/DTOs/Account/UpdateUserDto.cs b/API/DTOs/Account/UpdateUserDto.cs
index 546e1e4bd..6bf880074 100644
--- a/API/DTOs/Account/UpdateUserDto.cs
+++ b/API/DTOs/Account/UpdateUserDto.cs
@@ -1,4 +1,7 @@
using System.Collections.Generic;
+using System.Text.Json.Serialization;
+using API.Entities.Enums;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
namespace API.DTOs.Account;
@@ -13,5 +16,9 @@ public record UpdateUserDto
/// A list of libraries to grant access to
/// </summary>
public IList<int> Libraries { get; init; }
+ /// <summary>
+ /// An Age Rating which will limit the account to seeing everything equal to or below said rating.
+ /// </summary>
+ public AgeRating AgeRestriction { get; init; }
}
diff --git a/API/DTOs/MemberDto.cs b/API/DTOs/MemberDto.cs
index e8aa2834c..d2218c9ba 100644
--- a/API/DTOs/MemberDto.cs
+++ b/API/DTOs/MemberDto.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using API.Entities.Enums;
namespace API.DTOs;
@@ -11,6 +12,11 @@ public class MemberDto
public int Id { get; init; }
public string Username { get; init; }
public string Email { get; init; }
+
+ /// <summary>
+ /// The maximum age rating a user has access to. -1 if not applicable
+ /// </summary>
+ public AgeRating AgeRestriction { get; init; } = AgeRating.NotApplicable;
public DateTime Created { get; init; }
public DateTime LastActive { get; init; }
public IEnumerable<LibraryDto> Libraries { get; init; }
diff --git a/API/DTOs/UserDto.cs b/API/DTOs/UserDto.cs
index d2c05e5a8..210eefa09 100644
--- a/API/DTOs/UserDto.cs
+++ b/API/DTOs/UserDto.cs
@@ -1,4 +1,6 @@

+using API.Entities.Enums;
+
namespace API.DTOs;
public class UserDto
@@ -9,4 +11,8 @@ public class UserDto
public string RefreshToken { get; set; }
public string ApiKey { get; init; }
public UserPreferencesDto Preferences { get; set; }
+ /// <summary>
+ /// The highest age rating the user has access to. Not applicable for admins
+ /// </summary>
+ public AgeRating AgeRestriction { get; set; } = AgeRating.NotApplicable;
}
diff --git a/API/Data/MigrateChangeRestrictionRoles.cs b/API/Data/MigrateChangeRestrictionRoles.cs
new file mode 100644
index 000000000..25385823b
--- /dev/null
+++ b/API/Data/MigrateChangeRestrictionRoles.cs
@@ -0,0 +1,36 @@
+using System.Threading.Tasks;
+using API.Constants;
+using API.Entities;
+using Microsoft.AspNetCore.Identity;
+using Microsoft.Extensions.Logging;
+
+namespace API.Data;
+
+/// <summary>
+/// New role introduced in v0.6. Adds the role to all users.
+/// </summary>
+public static class MigrateChangeRestrictionRoles
+{
+ /// <summary>
+ /// Will not run if any users have the <see cref="PolicyConstants.ChangeRestrictionRole"/> role already
+ /// </summary>
+ /// <param name="unitOfWork"></param>
+ /// <param name="userManager"></param>
+ /// <param name="logger"></param>
+ public static async Task Migrate(IUnitOfWork unitOfWork, UserManager<AppUser> userManager, ILogger<Program> logger)
+ {
+ var usersWithRole = await userManager.GetUsersInRoleAsync(PolicyConstants.ChangeRestrictionRole);
+ if (usersWithRole.Count != 0) return;
+
+ logger.LogCritical("Running MigrateChangeRestrictionRoles migration");
+
+ var allUsers = await unitOfWork.UserRepository.GetAllUsers();
+ foreach (var user in allUsers)
+ {
+ await userManager.RemoveFromRoleAsync(user, PolicyConstants.ChangeRestrictionRole);
+ await userManager.AddToRoleAsync(user, PolicyConstants.ChangeRestrictionRole);
+ }
+
+ logger.LogInformation("MigrateChangeRestrictionRoles migration complete");
+ }
+}
diff --git a/API/Data/MigrateReadingListAgeRating.cs b/API/Data/MigrateReadingListAgeRating.cs
new file mode 100644
index 000000000..ebaa1ce03
--- /dev/null
+++ b/API/Data/MigrateReadingListAgeRating.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Threading.Tasks;
+using API.Constants;
+using API.Services;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Logging;
+using SQLitePCL;
+
+namespace API.Data;
+
+/// <summary>
+/// New role introduced in v0.6. Calculates the Age Rating on all Reading Lists
+/// </summary>
+public static class MigrateReadingListAgeRating
+{
+ /// <summary>
+ /// Will not run if any above v0.5.6.24 or v0.6.0
+ /// </summary>
+ /// <param name="context"></param>
+ /// <param name="readingListService"></param>
+ /// <param name="logger"></param>
+ public static async Task Migrate(IUnitOfWork unitOfWork, DataContext context, IReadingListService readingListService, ILogger<Program> logger)
+ {
+ var settings = await unitOfWork.SettingsRepository.GetSettingsDtoAsync();
+ if (Version.Parse(settings.InstallVersion) > new Version(0, 5, 6, 24))
+ {
+ return;
+ }
+
+ logger.LogInformation("MigrateReadingListAgeRating migration starting");
+ var readingLists = await context.ReadingList.Include(r => r.Items).ToListAsync();
+ foreach (var readingList in readingLists)
+ {
+ await readingListService.CalculateReadingListAgeRating(readingList);
+ context.ReadingList.Update(readingList);
+ }
+
+ await context.SaveChangesAsync();
+ logger.LogInformation("MigrateReadingListAgeRating migration complete");
+ }
+}
diff --git a/API/Data/Migrations/20221009172653_ReadingListAgeRating.Designer.cs b/API/Data/Migrations/20221009172653_ReadingListAgeRating.Designer.cs
new file mode 100644
index 000000000..f93e7a58d
--- /dev/null
+++ b/API/Data/Migrations/20221009172653_ReadingListAgeRating.Designer.cs
@@ -0,0 +1,1667 @@
+// <auto-generated />
+using System;
+using API.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace API.Data.Migrations
+{
+ [DbContext(typeof(DataContext))]
+ [Migration("20221009172653_ReadingListAgeRating")]
+ partial class ReadingListAgeRating
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "6.0.9");
+
+ modelBuilder.Entity("API.Entities.AppRole", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Name")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedName")
+ .IsUnique()
+ .HasDatabaseName("RoleNameIndex");
+
+ b.ToTable("AspNetRoles", (string)null);
+ });
+
+ modelBuilder.Entity("API.Entities.AppUser", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AccessFailedCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("ApiKey")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ConfirmationToken")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Email")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("EmailConfirmed")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("LastActive")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("LockoutEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTimeOffset?>("LockoutEnd")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedEmail")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedUserName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property<string>("PasswordHash")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("PhoneNumber")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("PhoneNumberConfirmed")
+ .HasColumnType("INTEGER");
+
+ b.Property<uint>("RowVersion")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("SecurityStamp")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("TwoFactorEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("UserName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedEmail")
+ .HasDatabaseName("EmailIndex");
+
+ b.HasIndex("NormalizedUserName")
+ .IsUnique()
+ .HasDatabaseName("UserNameIndex");
+
+ b.ToTable("AspNetUsers", (string)null);
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserBookmark", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ChapterId")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("FileName")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Page")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("VolumeId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.ToTable("AppUserBookmark");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserPreferences", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("AutoCloseMenu")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("BackgroundColor")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT")
+ .HasDefaultValue("#000000");
+
+ b.Property<bool>("BlurUnreadSummaries")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("BookReaderFontFamily")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("BookReaderFontSize")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("BookReaderImmersiveMode")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("BookReaderLayoutMode")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("BookReaderLineSpacing")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("BookReaderMargin")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("BookReaderReadingDirection")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("BookReaderTapToPaginate")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("BookThemeName")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT")
+ .HasDefaultValue("Dark");
+
+ b.Property<int>("GlobalPageLayoutMode")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(0);
+
+ b.Property<int>("LayoutMode")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("NoTransitions")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("PageSplitOption")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("PromptForDownloadSize")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ReaderMode")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ReadingDirection")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ScalingOption")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("ShowScreenHints")
+ .HasColumnType("INTEGER");
+
+ b.Property<int?>("ThemeId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId")
+ .IsUnique();
+
+ b.HasIndex("ThemeId");
+
+ b.ToTable("AppUserPreferences");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserProgress", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("BookScrollId")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("ChapterId")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("PagesRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("VolumeId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.HasIndex("SeriesId");
+
+ b.ToTable("AppUserProgresses");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRating", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Rating")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Review")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.HasIndex("SeriesId");
+
+ b.ToTable("AppUserRating");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRole", b =>
+ {
+ b.Property<int>("UserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("RoleId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("UserId", "RoleId");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetUserRoles", (string)null);
+ });
+
+ modelBuilder.Entity("API.Entities.Chapter", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AgeRating")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AvgHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Count")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("CoverImageLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("IsSpecial")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Language")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("MaxHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("MinHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Number")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Pages")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Range")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("ReleaseDate")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Summary")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Title")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("TitleName")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("TotalCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("VolumeId")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("WordCount")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("VolumeId");
+
+ b.ToTable("Chapter");
+ });
+
+ modelBuilder.Entity("API.Entities.CollectionTag", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("CoverImageLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("NormalizedTitle")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("Promoted")
+ .HasColumnType("INTEGER");
+
+ b.Property<uint>("RowVersion")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Summary")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Title")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Id", "Promoted")
+ .IsUnique();
+
+ b.ToTable("CollectionTag");
+ });
+
+ modelBuilder.Entity("API.Entities.Device", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("EmailAddress")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("IpAddress")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastUsed")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Platform")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.ToTable("Device");
+ });
+
+ modelBuilder.Entity("API.Entities.FolderPath", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("LastScanned")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("LibraryId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Path")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("LibraryId");
+
+ b.ToTable("FolderPath");
+ });
+
+ modelBuilder.Entity("API.Entities.Genre", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("ExternalTag")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("NormalizedTitle")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Title")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedTitle", "ExternalTag")
+ .IsUnique();
+
+ b.ToTable("Genre");
+ });
+
+ modelBuilder.Entity("API.Entities.Library", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastScanned")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Type")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("Library");
+ });
+
+ modelBuilder.Entity("API.Entities.MangaFile", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ChapterId")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("FilePath")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Format")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("LastFileAnalysis")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Pages")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ChapterId");
+
+ b.ToTable("MangaFile");
+ });
+
+ modelBuilder.Entity("API.Entities.Metadata.SeriesMetadata", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AgeRating")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("AgeRatingLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("CharacterLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("ColoristLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("CoverArtistLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("EditorLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("GenresLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("InkerLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Language")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("LanguageLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("LettererLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("MaxCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("PencillerLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("PublicationStatus")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("PublicationStatusLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("PublisherLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ReleaseYear")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("ReleaseYearLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<uint>("RowVersion")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Summary")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("SummaryLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("TagsLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("TotalCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("TranslatorLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("WriterLocked")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SeriesId")
+ .IsUnique();
+
+ b.HasIndex("Id", "SeriesId")
+ .IsUnique();
+
+ b.ToTable("SeriesMetadata");
+ });
+
+ modelBuilder.Entity("API.Entities.Metadata.SeriesRelation", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("RelationKind")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("TargetSeriesId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SeriesId");
+
+ b.HasIndex("TargetSeriesId");
+
+ b.ToTable("SeriesRelation");
+ });
+
+ modelBuilder.Entity("API.Entities.Person", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedName")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Role")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("Person");
+ });
+
+ modelBuilder.Entity("API.Entities.ReadingList", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AgeRating")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("CoverImageLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedTitle")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("Promoted")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Summary")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Title")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.ToTable("ReadingList");
+ });
+
+ modelBuilder.Entity("API.Entities.ReadingListItem", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ChapterId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Order")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ReadingListId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("VolumeId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ChapterId");
+
+ b.HasIndex("ReadingListId");
+
+ b.HasIndex("SeriesId");
+
+ b.HasIndex("VolumeId");
+
+ b.ToTable("ReadingListItem");
+ });
+
+ modelBuilder.Entity("API.Entities.Series", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int?>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AvgHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("CoverImageLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("FolderPath")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Format")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("LastChapterAdded")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastFolderScanned")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("LibraryId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("LocalizedName")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("LocalizedNameLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("MaxHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("MinHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("NameLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("NormalizedLocalizedName")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedName")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("OriginalName")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Pages")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("SortName")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("SortNameLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("WordCount")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.HasIndex("LibraryId");
+
+ b.ToTable("Series");
+ });
+
+ modelBuilder.Entity("API.Entities.ServerSetting", b =>
+ {
+ b.Property<int>("Key")
+ .HasColumnType("INTEGER");
+
+ b.Property<uint>("RowVersion")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Value")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Key");
+
+ b.ToTable("ServerSetting");
+ });
+
+ modelBuilder.Entity("API.Entities.SiteTheme", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("FileName")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("IsDefault")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedName")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Provider")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("SiteTheme");
+ });
+
+ modelBuilder.Entity("API.Entities.Tag", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("ExternalTag")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("NormalizedTitle")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Title")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedTitle", "ExternalTag")
+ .IsUnique();
+
+ b.ToTable("Tag");
+ });
+
+ modelBuilder.Entity("API.Entities.Volume", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AvgHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("MaxHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("MinHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Number")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Pages")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("WordCount")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SeriesId");
+
+ b.ToTable("Volume");
+ });
+
+ modelBuilder.Entity("AppUserLibrary", b =>
+ {
+ b.Property<int>("AppUsersId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("LibrariesId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("AppUsersId", "LibrariesId");
+
+ b.HasIndex("LibrariesId");
+
+ b.ToTable("AppUserLibrary");
+ });
+
+ modelBuilder.Entity("ChapterGenre", b =>
+ {
+ b.Property<int>("ChaptersId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("GenresId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("ChaptersId", "GenresId");
+
+ b.HasIndex("GenresId");
+
+ b.ToTable("ChapterGenre");
+ });
+
+ modelBuilder.Entity("ChapterPerson", b =>
+ {
+ b.Property<int>("ChapterMetadatasId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("PeopleId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("ChapterMetadatasId", "PeopleId");
+
+ b.HasIndex("PeopleId");
+
+ b.ToTable("ChapterPerson");
+ });
+
+ modelBuilder.Entity("ChapterTag", b =>
+ {
+ b.Property<int>("ChaptersId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("TagsId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("ChaptersId", "TagsId");
+
+ b.HasIndex("TagsId");
+
+ b.ToTable("ChapterTag");
+ });
+
+ modelBuilder.Entity("CollectionTagSeriesMetadata", b =>
+ {
+ b.Property<int>("CollectionTagsId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesMetadatasId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("CollectionTagsId", "SeriesMetadatasId");
+
+ b.HasIndex("SeriesMetadatasId");
+
+ b.ToTable("CollectionTagSeriesMetadata");
+ });
+
+ modelBuilder.Entity("GenreSeriesMetadata", b =>
+ {
+ b.Property<int>("GenresId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesMetadatasId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("GenresId", "SeriesMetadatasId");
+
+ b.HasIndex("SeriesMetadatasId");
+
+ b.ToTable("GenreSeriesMetadata");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("ClaimType")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ClaimValue")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("RoleId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetRoleClaims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("ClaimType")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ClaimValue")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserClaims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
+ {
+ b.Property<string>("LoginProvider")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ProviderKey")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ProviderDisplayName")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("LoginProvider", "ProviderKey");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserLogins", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
+ {
+ b.Property<int>("UserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("LoginProvider")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Value")
+ .HasColumnType("TEXT");
+
+ b.HasKey("UserId", "LoginProvider", "Name");
+
+ b.ToTable("AspNetUserTokens", (string)null);
+ });
+
+ modelBuilder.Entity("PersonSeriesMetadata", b =>
+ {
+ b.Property<int>("PeopleId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesMetadatasId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("PeopleId", "SeriesMetadatasId");
+
+ b.HasIndex("SeriesMetadatasId");
+
+ b.ToTable("PersonSeriesMetadata");
+ });
+
+ modelBuilder.Entity("SeriesMetadataTag", b =>
+ {
+ b.Property<int>("SeriesMetadatasId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("TagsId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("SeriesMetadatasId", "TagsId");
+
+ b.HasIndex("TagsId");
+
+ b.ToTable("SeriesMetadataTag");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserBookmark", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithMany("Bookmarks")
+ .HasForeignKey("AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("AppUser");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserPreferences", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithOne("UserPreferences")
+ .HasForeignKey("API.Entities.AppUserPreferences", "AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.SiteTheme", "Theme")
+ .WithMany()
+ .HasForeignKey("ThemeId");
+
+ b.Navigation("AppUser");
+
+ b.Navigation("Theme");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserProgress", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithMany("Progresses")
+ .HasForeignKey("AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Series", null)
+ .WithMany("Progress")
+ .HasForeignKey("SeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("AppUser");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRating", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithMany("Ratings")
+ .HasForeignKey("AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Series", null)
+ .WithMany("Ratings")
+ .HasForeignKey("SeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("AppUser");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRole", b =>
+ {
+ b.HasOne("API.Entities.AppRole", "Role")
+ .WithMany("UserRoles")
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.AppUser", "User")
+ .WithMany("UserRoles")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Role");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("API.Entities.Chapter", b =>
+ {
+ b.HasOne("API.Entities.Volume", "Volume")
+ .WithMany("Chapters")
+ .HasForeignKey("VolumeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Volume");
+ });
+
+ modelBuilder.Entity("API.Entities.Device", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithMany("Devices")
+ .HasForeignKey("AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("AppUser");
+ });
+
+ modelBuilder.Entity("API.Entities.FolderPath", b =>
+ {
+ b.HasOne("API.Entities.Library", "Library")
+ .WithMany("Folders")
+ .HasForeignKey("LibraryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Library");
+ });
+
+ modelBuilder.Entity("API.Entities.MangaFile", b =>
+ {
+ b.HasOne("API.Entities.Chapter", "Chapter")
+ .WithMany("Files")
+ .HasForeignKey("ChapterId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Chapter");
+ });
+
+ modelBuilder.Entity("API.Entities.Metadata.SeriesMetadata", b =>
+ {
+ b.HasOne("API.Entities.Series", "Series")
+ .WithOne("Metadata")
+ .HasForeignKey("API.Entities.Metadata.SeriesMetadata", "SeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Series");
+ });
+
+ modelBuilder.Entity("API.Entities.Metadata.SeriesRelation", b =>
+ {
+ b.HasOne("API.Entities.Series", "Series")
+ .WithMany("Relations")
+ .HasForeignKey("SeriesId")
+ .OnDelete(DeleteBehavior.ClientCascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Series", "TargetSeries")
+ .WithMany("RelationOf")
+ .HasForeignKey("TargetSeriesId")
+ .OnDelete(DeleteBehavior.ClientCascade)
+ .IsRequired();
+
+ b.Navigation("Series");
+
+ b.Navigation("TargetSeries");
+ });
+
+ modelBuilder.Entity("API.Entities.ReadingList", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithMany("ReadingLists")
+ .HasForeignKey("AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("AppUser");
+ });
+
+ modelBuilder.Entity("API.Entities.ReadingListItem", b =>
+ {
+ b.HasOne("API.Entities.Chapter", "Chapter")
+ .WithMany()
+ .HasForeignKey("ChapterId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.ReadingList", "ReadingList")
+ .WithMany("Items")
+ .HasForeignKey("ReadingListId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Series", "Series")
+ .WithMany()
+ .HasForeignKey("SeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Volume", "Volume")
+ .WithMany()
+ .HasForeignKey("VolumeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Chapter");
+
+ b.Navigation("ReadingList");
+
+ b.Navigation("Series");
+
+ b.Navigation("Volume");
+ });
+
+ modelBuilder.Entity("API.Entities.Series", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany("WantToRead")
+ .HasForeignKey("AppUserId");
+
+ b.HasOne("API.Entities.Library", "Library")
+ .WithMany("Series")
+ .HasForeignKey("LibraryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Library");
+ });
+
+ modelBuilder.Entity("API.Entities.Volume", b =>
+ {
+ b.HasOne("API.Entities.Series", "Series")
+ .WithMany("Volumes")
+ .HasForeignKey("SeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Series");
+ });
+
+ modelBuilder.Entity("AppUserLibrary", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany()
+ .HasForeignKey("AppUsersId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Library", null)
+ .WithMany()
+ .HasForeignKey("LibrariesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("ChapterGenre", b =>
+ {
+ b.HasOne("API.Entities.Chapter", null)
+ .WithMany()
+ .HasForeignKey("ChaptersId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Genre", null)
+ .WithMany()
+ .HasForeignKey("GenresId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("ChapterPerson", b =>
+ {
+ b.HasOne("API.Entities.Chapter", null)
+ .WithMany()
+ .HasForeignKey("ChapterMetadatasId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Person", null)
+ .WithMany()
+ .HasForeignKey("PeopleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("ChapterTag", b =>
+ {
+ b.HasOne("API.Entities.Chapter", null)
+ .WithMany()
+ .HasForeignKey("ChaptersId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Tag", null)
+ .WithMany()
+ .HasForeignKey("TagsId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("CollectionTagSeriesMetadata", b =>
+ {
+ b.HasOne("API.Entities.CollectionTag", null)
+ .WithMany()
+ .HasForeignKey("CollectionTagsId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Metadata.SeriesMetadata", null)
+ .WithMany()
+ .HasForeignKey("SeriesMetadatasId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("GenreSeriesMetadata", b =>
+ {
+ b.HasOne("API.Entities.Genre", null)
+ .WithMany()
+ .HasForeignKey("GenresId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Metadata.SeriesMetadata", null)
+ .WithMany()
+ .HasForeignKey("SeriesMetadatasId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
+ {
+ b.HasOne("API.Entities.AppRole", null)
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("PersonSeriesMetadata", b =>
+ {
+ b.HasOne("API.Entities.Person", null)
+ .WithMany()
+ .HasForeignKey("PeopleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Metadata.SeriesMetadata", null)
+ .WithMany()
+ .HasForeignKey("SeriesMetadatasId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("SeriesMetadataTag", b =>
+ {
+ b.HasOne("API.Entities.Metadata.SeriesMetadata", null)
+ .WithMany()
+ .HasForeignKey("SeriesMetadatasId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Tag", null)
+ .WithMany()
+ .HasForeignKey("TagsId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("API.Entities.AppRole", b =>
+ {
+ b.Navigation("UserRoles");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUser", b =>
+ {
+ b.Navigation("Bookmarks");
+
+ b.Navigation("Devices");
+
+ b.Navigation("Progresses");
+
+ b.Navigation("Ratings");
+
+ b.Navigation("ReadingLists");
+
+ b.Navigation("UserPreferences");
+
+ b.Navigation("UserRoles");
+
+ b.Navigation("WantToRead");
+ });
+
+ modelBuilder.Entity("API.Entities.Chapter", b =>
+ {
+ b.Navigation("Files");
+ });
+
+ modelBuilder.Entity("API.Entities.Library", b =>
+ {
+ b.Navigation("Folders");
+
+ b.Navigation("Series");
+ });
+
+ modelBuilder.Entity("API.Entities.ReadingList", b =>
+ {
+ b.Navigation("Items");
+ });
+
+ modelBuilder.Entity("API.Entities.Series", b =>
+ {
+ b.Navigation("Metadata");
+
+ b.Navigation("Progress");
+
+ b.Navigation("Ratings");
+
+ b.Navigation("RelationOf");
+
+ b.Navigation("Relations");
+
+ b.Navigation("Volumes");
+ });
+
+ modelBuilder.Entity("API.Entities.Volume", b =>
+ {
+ b.Navigation("Chapters");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/API/Data/Migrations/20221009172653_ReadingListAgeRating.cs b/API/Data/Migrations/20221009172653_ReadingListAgeRating.cs
new file mode 100644
index 000000000..dfc69a9cf
--- /dev/null
+++ b/API/Data/Migrations/20221009172653_ReadingListAgeRating.cs
@@ -0,0 +1,26 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace API.Data.Migrations
+{
+ public partial class ReadingListAgeRating : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn<int>(
+ name: "AgeRating",
+ table: "ReadingList",
+ type: "INTEGER",
+ nullable: false,
+ defaultValue: 0);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "AgeRating",
+ table: "ReadingList");
+ }
+ }
+}
diff --git a/API/Data/Migrations/20221009211237_UserAgeRating.Designer.cs b/API/Data/Migrations/20221009211237_UserAgeRating.Designer.cs
new file mode 100644
index 000000000..1a9e9fade
--- /dev/null
+++ b/API/Data/Migrations/20221009211237_UserAgeRating.Designer.cs
@@ -0,0 +1,1670 @@
+// <auto-generated />
+using System;
+using API.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace API.Data.Migrations
+{
+ [DbContext(typeof(DataContext))]
+ [Migration("20221009211237_UserAgeRating")]
+ partial class UserAgeRating
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "6.0.9");
+
+ modelBuilder.Entity("API.Entities.AppRole", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Name")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedName")
+ .IsUnique()
+ .HasDatabaseName("RoleNameIndex");
+
+ b.ToTable("AspNetRoles", (string)null);
+ });
+
+ modelBuilder.Entity("API.Entities.AppUser", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AccessFailedCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AgeRestriction")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("ApiKey")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ConfirmationToken")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Email")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("EmailConfirmed")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("LastActive")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("LockoutEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTimeOffset?>("LockoutEnd")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedEmail")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedUserName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property<string>("PasswordHash")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("PhoneNumber")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("PhoneNumberConfirmed")
+ .HasColumnType("INTEGER");
+
+ b.Property<uint>("RowVersion")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("SecurityStamp")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("TwoFactorEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("UserName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedEmail")
+ .HasDatabaseName("EmailIndex");
+
+ b.HasIndex("NormalizedUserName")
+ .IsUnique()
+ .HasDatabaseName("UserNameIndex");
+
+ b.ToTable("AspNetUsers", (string)null);
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserBookmark", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ChapterId")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("FileName")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Page")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("VolumeId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.ToTable("AppUserBookmark");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserPreferences", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("AutoCloseMenu")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("BackgroundColor")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT")
+ .HasDefaultValue("#000000");
+
+ b.Property<bool>("BlurUnreadSummaries")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("BookReaderFontFamily")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("BookReaderFontSize")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("BookReaderImmersiveMode")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("BookReaderLayoutMode")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("BookReaderLineSpacing")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("BookReaderMargin")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("BookReaderReadingDirection")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("BookReaderTapToPaginate")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("BookThemeName")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT")
+ .HasDefaultValue("Dark");
+
+ b.Property<int>("GlobalPageLayoutMode")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER")
+ .HasDefaultValue(0);
+
+ b.Property<int>("LayoutMode")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("NoTransitions")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("PageSplitOption")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("PromptForDownloadSize")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ReaderMode")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ReadingDirection")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ScalingOption")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("ShowScreenHints")
+ .HasColumnType("INTEGER");
+
+ b.Property<int?>("ThemeId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId")
+ .IsUnique();
+
+ b.HasIndex("ThemeId");
+
+ b.ToTable("AppUserPreferences");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserProgress", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("BookScrollId")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("ChapterId")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("PagesRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("VolumeId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.HasIndex("SeriesId");
+
+ b.ToTable("AppUserProgresses");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRating", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Rating")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Review")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.HasIndex("SeriesId");
+
+ b.ToTable("AppUserRating");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRole", b =>
+ {
+ b.Property<int>("UserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("RoleId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("UserId", "RoleId");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetUserRoles", (string)null);
+ });
+
+ modelBuilder.Entity("API.Entities.Chapter", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AgeRating")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AvgHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Count")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("CoverImageLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("IsSpecial")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Language")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("MaxHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("MinHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Number")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Pages")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Range")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("ReleaseDate")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Summary")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Title")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("TitleName")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("TotalCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("VolumeId")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("WordCount")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("VolumeId");
+
+ b.ToTable("Chapter");
+ });
+
+ modelBuilder.Entity("API.Entities.CollectionTag", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("CoverImageLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("NormalizedTitle")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("Promoted")
+ .HasColumnType("INTEGER");
+
+ b.Property<uint>("RowVersion")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Summary")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Title")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Id", "Promoted")
+ .IsUnique();
+
+ b.ToTable("CollectionTag");
+ });
+
+ modelBuilder.Entity("API.Entities.Device", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("EmailAddress")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("IpAddress")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastUsed")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Platform")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.ToTable("Device");
+ });
+
+ modelBuilder.Entity("API.Entities.FolderPath", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("LastScanned")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("LibraryId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Path")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("LibraryId");
+
+ b.ToTable("FolderPath");
+ });
+
+ modelBuilder.Entity("API.Entities.Genre", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("ExternalTag")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("NormalizedTitle")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Title")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedTitle", "ExternalTag")
+ .IsUnique();
+
+ b.ToTable("Genre");
+ });
+
+ modelBuilder.Entity("API.Entities.Library", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastScanned")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Type")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("Library");
+ });
+
+ modelBuilder.Entity("API.Entities.MangaFile", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ChapterId")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("FilePath")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Format")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("LastFileAnalysis")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Pages")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ChapterId");
+
+ b.ToTable("MangaFile");
+ });
+
+ modelBuilder.Entity("API.Entities.Metadata.SeriesMetadata", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AgeRating")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("AgeRatingLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("CharacterLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("ColoristLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("CoverArtistLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("EditorLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("GenresLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("InkerLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Language")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("LanguageLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("LettererLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("MaxCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("PencillerLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("PublicationStatus")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("PublicationStatusLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("PublisherLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ReleaseYear")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("ReleaseYearLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<uint>("RowVersion")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Summary")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("SummaryLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("TagsLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("TotalCount")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("TranslatorLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("WriterLocked")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SeriesId")
+ .IsUnique();
+
+ b.HasIndex("Id", "SeriesId")
+ .IsUnique();
+
+ b.ToTable("SeriesMetadata");
+ });
+
+ modelBuilder.Entity("API.Entities.Metadata.SeriesRelation", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("RelationKind")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("TargetSeriesId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SeriesId");
+
+ b.HasIndex("TargetSeriesId");
+
+ b.ToTable("SeriesRelation");
+ });
+
+ modelBuilder.Entity("API.Entities.Person", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedName")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Role")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("Person");
+ });
+
+ modelBuilder.Entity("API.Entities.ReadingList", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AgeRating")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("CoverImageLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedTitle")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("Promoted")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Summary")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Title")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.ToTable("ReadingList");
+ });
+
+ modelBuilder.Entity("API.Entities.ReadingListItem", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ChapterId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Order")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ReadingListId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("VolumeId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ChapterId");
+
+ b.HasIndex("ReadingListId");
+
+ b.HasIndex("SeriesId");
+
+ b.HasIndex("VolumeId");
+
+ b.ToTable("ReadingListItem");
+ });
+
+ modelBuilder.Entity("API.Entities.Series", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int?>("AppUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AvgHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("CoverImageLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("FolderPath")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Format")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("LastChapterAdded")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastFolderScanned")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("LibraryId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("LocalizedName")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("LocalizedNameLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("MaxHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("MinHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("NameLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("NormalizedLocalizedName")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedName")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("OriginalName")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Pages")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("SortName")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("SortNameLocked")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("WordCount")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AppUserId");
+
+ b.HasIndex("LibraryId");
+
+ b.ToTable("Series");
+ });
+
+ modelBuilder.Entity("API.Entities.ServerSetting", b =>
+ {
+ b.Property<int>("Key")
+ .HasColumnType("INTEGER");
+
+ b.Property<uint>("RowVersion")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Value")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Key");
+
+ b.ToTable("ServerSetting");
+ });
+
+ modelBuilder.Entity("API.Entities.SiteTheme", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("FileName")
+ .HasColumnType("TEXT");
+
+ b.Property<bool>("IsDefault")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("NormalizedName")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Provider")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("SiteTheme");
+ });
+
+ modelBuilder.Entity("API.Entities.Tag", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<bool>("ExternalTag")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("NormalizedTitle")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Title")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedTitle", "ExternalTag")
+ .IsUnique();
+
+ b.ToTable("Tag");
+ });
+
+ modelBuilder.Entity("API.Entities.Volume", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("AvgHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("CoverImage")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("Created")
+ .HasColumnType("TEXT");
+
+ b.Property<DateTime>("LastModified")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("MaxHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("MinHoursToRead")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("Number")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("Pages")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesId")
+ .HasColumnType("INTEGER");
+
+ b.Property<long>("WordCount")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SeriesId");
+
+ b.ToTable("Volume");
+ });
+
+ modelBuilder.Entity("AppUserLibrary", b =>
+ {
+ b.Property<int>("AppUsersId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("LibrariesId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("AppUsersId", "LibrariesId");
+
+ b.HasIndex("LibrariesId");
+
+ b.ToTable("AppUserLibrary");
+ });
+
+ modelBuilder.Entity("ChapterGenre", b =>
+ {
+ b.Property<int>("ChaptersId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("GenresId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("ChaptersId", "GenresId");
+
+ b.HasIndex("GenresId");
+
+ b.ToTable("ChapterGenre");
+ });
+
+ modelBuilder.Entity("ChapterPerson", b =>
+ {
+ b.Property<int>("ChapterMetadatasId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("PeopleId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("ChapterMetadatasId", "PeopleId");
+
+ b.HasIndex("PeopleId");
+
+ b.ToTable("ChapterPerson");
+ });
+
+ modelBuilder.Entity("ChapterTag", b =>
+ {
+ b.Property<int>("ChaptersId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("TagsId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("ChaptersId", "TagsId");
+
+ b.HasIndex("TagsId");
+
+ b.ToTable("ChapterTag");
+ });
+
+ modelBuilder.Entity("CollectionTagSeriesMetadata", b =>
+ {
+ b.Property<int>("CollectionTagsId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesMetadatasId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("CollectionTagsId", "SeriesMetadatasId");
+
+ b.HasIndex("SeriesMetadatasId");
+
+ b.ToTable("CollectionTagSeriesMetadata");
+ });
+
+ modelBuilder.Entity("GenreSeriesMetadata", b =>
+ {
+ b.Property<int>("GenresId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesMetadatasId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("GenresId", "SeriesMetadatasId");
+
+ b.HasIndex("SeriesMetadatasId");
+
+ b.ToTable("GenreSeriesMetadata");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("ClaimType")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ClaimValue")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("RoleId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetRoleClaims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("ClaimType")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ClaimValue")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserClaims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
+ {
+ b.Property<string>("LoginProvider")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ProviderKey")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("ProviderDisplayName")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("LoginProvider", "ProviderKey");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserLogins", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
+ {
+ b.Property<int>("UserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("LoginProvider")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Name")
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Value")
+ .HasColumnType("TEXT");
+
+ b.HasKey("UserId", "LoginProvider", "Name");
+
+ b.ToTable("AspNetUserTokens", (string)null);
+ });
+
+ modelBuilder.Entity("PersonSeriesMetadata", b =>
+ {
+ b.Property<int>("PeopleId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SeriesMetadatasId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("PeopleId", "SeriesMetadatasId");
+
+ b.HasIndex("SeriesMetadatasId");
+
+ b.ToTable("PersonSeriesMetadata");
+ });
+
+ modelBuilder.Entity("SeriesMetadataTag", b =>
+ {
+ b.Property<int>("SeriesMetadatasId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("TagsId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("SeriesMetadatasId", "TagsId");
+
+ b.HasIndex("TagsId");
+
+ b.ToTable("SeriesMetadataTag");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserBookmark", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithMany("Bookmarks")
+ .HasForeignKey("AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("AppUser");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserPreferences", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithOne("UserPreferences")
+ .HasForeignKey("API.Entities.AppUserPreferences", "AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.SiteTheme", "Theme")
+ .WithMany()
+ .HasForeignKey("ThemeId");
+
+ b.Navigation("AppUser");
+
+ b.Navigation("Theme");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserProgress", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithMany("Progresses")
+ .HasForeignKey("AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Series", null)
+ .WithMany("Progress")
+ .HasForeignKey("SeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("AppUser");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRating", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithMany("Ratings")
+ .HasForeignKey("AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Series", null)
+ .WithMany("Ratings")
+ .HasForeignKey("SeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("AppUser");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUserRole", b =>
+ {
+ b.HasOne("API.Entities.AppRole", "Role")
+ .WithMany("UserRoles")
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.AppUser", "User")
+ .WithMany("UserRoles")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Role");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("API.Entities.Chapter", b =>
+ {
+ b.HasOne("API.Entities.Volume", "Volume")
+ .WithMany("Chapters")
+ .HasForeignKey("VolumeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Volume");
+ });
+
+ modelBuilder.Entity("API.Entities.Device", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithMany("Devices")
+ .HasForeignKey("AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("AppUser");
+ });
+
+ modelBuilder.Entity("API.Entities.FolderPath", b =>
+ {
+ b.HasOne("API.Entities.Library", "Library")
+ .WithMany("Folders")
+ .HasForeignKey("LibraryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Library");
+ });
+
+ modelBuilder.Entity("API.Entities.MangaFile", b =>
+ {
+ b.HasOne("API.Entities.Chapter", "Chapter")
+ .WithMany("Files")
+ .HasForeignKey("ChapterId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Chapter");
+ });
+
+ modelBuilder.Entity("API.Entities.Metadata.SeriesMetadata", b =>
+ {
+ b.HasOne("API.Entities.Series", "Series")
+ .WithOne("Metadata")
+ .HasForeignKey("API.Entities.Metadata.SeriesMetadata", "SeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Series");
+ });
+
+ modelBuilder.Entity("API.Entities.Metadata.SeriesRelation", b =>
+ {
+ b.HasOne("API.Entities.Series", "Series")
+ .WithMany("Relations")
+ .HasForeignKey("SeriesId")
+ .OnDelete(DeleteBehavior.ClientCascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Series", "TargetSeries")
+ .WithMany("RelationOf")
+ .HasForeignKey("TargetSeriesId")
+ .OnDelete(DeleteBehavior.ClientCascade)
+ .IsRequired();
+
+ b.Navigation("Series");
+
+ b.Navigation("TargetSeries");
+ });
+
+ modelBuilder.Entity("API.Entities.ReadingList", b =>
+ {
+ b.HasOne("API.Entities.AppUser", "AppUser")
+ .WithMany("ReadingLists")
+ .HasForeignKey("AppUserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("AppUser");
+ });
+
+ modelBuilder.Entity("API.Entities.ReadingListItem", b =>
+ {
+ b.HasOne("API.Entities.Chapter", "Chapter")
+ .WithMany()
+ .HasForeignKey("ChapterId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.ReadingList", "ReadingList")
+ .WithMany("Items")
+ .HasForeignKey("ReadingListId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Series", "Series")
+ .WithMany()
+ .HasForeignKey("SeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Volume", "Volume")
+ .WithMany()
+ .HasForeignKey("VolumeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Chapter");
+
+ b.Navigation("ReadingList");
+
+ b.Navigation("Series");
+
+ b.Navigation("Volume");
+ });
+
+ modelBuilder.Entity("API.Entities.Series", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany("WantToRead")
+ .HasForeignKey("AppUserId");
+
+ b.HasOne("API.Entities.Library", "Library")
+ .WithMany("Series")
+ .HasForeignKey("LibraryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Library");
+ });
+
+ modelBuilder.Entity("API.Entities.Volume", b =>
+ {
+ b.HasOne("API.Entities.Series", "Series")
+ .WithMany("Volumes")
+ .HasForeignKey("SeriesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Series");
+ });
+
+ modelBuilder.Entity("AppUserLibrary", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany()
+ .HasForeignKey("AppUsersId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Library", null)
+ .WithMany()
+ .HasForeignKey("LibrariesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("ChapterGenre", b =>
+ {
+ b.HasOne("API.Entities.Chapter", null)
+ .WithMany()
+ .HasForeignKey("ChaptersId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Genre", null)
+ .WithMany()
+ .HasForeignKey("GenresId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("ChapterPerson", b =>
+ {
+ b.HasOne("API.Entities.Chapter", null)
+ .WithMany()
+ .HasForeignKey("ChapterMetadatasId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Person", null)
+ .WithMany()
+ .HasForeignKey("PeopleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("ChapterTag", b =>
+ {
+ b.HasOne("API.Entities.Chapter", null)
+ .WithMany()
+ .HasForeignKey("ChaptersId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Tag", null)
+ .WithMany()
+ .HasForeignKey("TagsId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("CollectionTagSeriesMetadata", b =>
+ {
+ b.HasOne("API.Entities.CollectionTag", null)
+ .WithMany()
+ .HasForeignKey("CollectionTagsId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Metadata.SeriesMetadata", null)
+ .WithMany()
+ .HasForeignKey("SeriesMetadatasId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("GenreSeriesMetadata", b =>
+ {
+ b.HasOne("API.Entities.Genre", null)
+ .WithMany()
+ .HasForeignKey("GenresId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Metadata.SeriesMetadata", null)
+ .WithMany()
+ .HasForeignKey("SeriesMetadatasId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
+ {
+ b.HasOne("API.Entities.AppRole", null)
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
+ {
+ b.HasOne("API.Entities.AppUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("PersonSeriesMetadata", b =>
+ {
+ b.HasOne("API.Entities.Person", null)
+ .WithMany()
+ .HasForeignKey("PeopleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Metadata.SeriesMetadata", null)
+ .WithMany()
+ .HasForeignKey("SeriesMetadatasId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("SeriesMetadataTag", b =>
+ {
+ b.HasOne("API.Entities.Metadata.SeriesMetadata", null)
+ .WithMany()
+ .HasForeignKey("SeriesMetadatasId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("API.Entities.Tag", null)
+ .WithMany()
+ .HasForeignKey("TagsId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("API.Entities.AppRole", b =>
+ {
+ b.Navigation("UserRoles");
+ });
+
+ modelBuilder.Entity("API.Entities.AppUser", b =>
+ {
+ b.Navigation("Bookmarks");
+
+ b.Navigation("Devices");
+
+ b.Navigation("Progresses");
+
+ b.Navigation("Ratings");
+
+ b.Navigation("ReadingLists");
+
+ b.Navigation("UserPreferences");
+
+ b.Navigation("UserRoles");
+
+ b.Navigation("WantToRead");
+ });
+
+ modelBuilder.Entity("API.Entities.Chapter", b =>
+ {
+ b.Navigation("Files");
+ });
+
+ modelBuilder.Entity("API.Entities.Library", b =>
+ {
+ b.Navigation("Folders");
+
+ b.Navigation("Series");
+ });
+
+ modelBuilder.Entity("API.Entities.ReadingList", b =>
+ {
+ b.Navigation("Items");
+ });
+
+ modelBuilder.Entity("API.Entities.Series", b =>
+ {
+ b.Navigation("Metadata");
+
+ b.Navigation("Progress");
+
+ b.Navigation("Ratings");
+
+ b.Navigation("RelationOf");
+
+ b.Navigation("Relations");
+
+ b.Navigation("Volumes");
+ });
+
+ modelBuilder.Entity("API.Entities.Volume", b =>
+ {
+ b.Navigation("Chapters");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/API/Data/Migrations/20221009211237_UserAgeRating.cs b/API/Data/Migrations/20221009211237_UserAgeRating.cs
new file mode 100644
index 000000000..a619255ef
--- /dev/null
+++ b/API/Data/Migrations/20221009211237_UserAgeRating.cs
@@ -0,0 +1,27 @@
+using API.Entities.Enums;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace API.Data.Migrations
+{
+ public partial class UserAgeRating : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn<int>(
+ name: "AgeRestriction",
+ table: "AspNetUsers",
+ type: "INTEGER",
+ nullable: false,
+ defaultValue: AgeRating.NotApplicable);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "AgeRestriction",
+ table: "AspNetUsers");
+ }
+ }
+}
diff --git a/API/Data/Migrations/DataContextModelSnapshot.cs b/API/Data/Migrations/DataContextModelSnapshot.cs
index 9462617fe..80b841b8b 100644
--- a/API/Data/Migrations/DataContextModelSnapshot.cs
+++ b/API/Data/Migrations/DataContextModelSnapshot.cs
@@ -53,6 +53,9 @@ namespace API.Data.Migrations
b.Property<int>("AccessFailedCount")
.HasColumnType("INTEGER");
+ b.Property<int>("AgeRestriction")
+ .HasColumnType("INTEGER");
+
b.Property<string>("ApiKey")
.HasColumnType("TEXT");
@@ -736,6 +739,9 @@ namespace API.Data.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
+ b.Property<int>("AgeRating")
+ .HasColumnType("INTEGER");
+
b.Property<int>("AppUserId")
.HasColumnType("INTEGER");
diff --git a/API/Data/Repositories/CollectionTagRepository.cs b/API/Data/Repositories/CollectionTagRepository.cs
index 7b9398b85..a88a98adf 100644
--- a/API/Data/Repositories/CollectionTagRepository.cs
+++ b/API/Data/Repositories/CollectionTagRepository.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Threading.Tasks;
using API.DTOs.CollectionTags;
using API.Entities;
+using API.Extensions;
using AutoMapper;
using AutoMapper.QueryableExtensions;
using Microsoft.EntityFrameworkCore;
@@ -15,9 +16,9 @@ public interface ICollectionTagRepository
void Add(CollectionTag tag);
void Remove(CollectionTag tag);
Task<IEnumerable<CollectionTagDto>> GetAllTagDtosAsync();
- Task<IEnumerable<CollectionTagDto>> SearchTagDtosAsync(string searchQuery);
+ Task<IEnumerable<CollectionTagDto>> SearchTagDtosAsync(string searchQuery, int userId);
Task<string> GetCoverImageAsync(int collectionTagId);
- Task<IEnumerable<CollectionTagDto>> GetAllPromotedTagDtosAsync();
+ Task<IEnumerable<CollectionTagDto>> GetAllPromotedTagDtosAsync(int userId);
Task<CollectionTag> GetTagAsync(int tagId);
Task<CollectionTag> GetFullTagAsync(int tagId);
void Update(CollectionTag tag);
@@ -85,6 +86,7 @@ public class CollectionTagRepository : ICollectionTagRepository
public async Task<IEnumerable<CollectionTagDto>> GetAllTagDtosAsync()
{
+
return await _context.CollectionTag
.OrderBy(c => c.NormalizedTitle)
.AsNoTracking()
@@ -92,10 +94,12 @@ public class CollectionTagRepository : ICollectionTagRepository
.ToListAsync();
}
- public async Task<IEnumerable<CollectionTagDto>> GetAllPromotedTagDtosAsync()
+ public async Task<IEnumerable<CollectionTagDto>> GetAllPromotedTagDtosAsync(int userId)
{
+ var userRating = (await _context.AppUser.SingleAsync(u => u.Id == userId)).AgeRestriction;
return await _context.CollectionTag
.Where(c => c.Promoted)
+ .RestrictAgainstAgeRestriction(userRating)
.OrderBy(c => c.NormalizedTitle)
.AsNoTracking()
.ProjectTo<CollectionTagDto>(_mapper.ConfigurationProvider)
@@ -118,11 +122,13 @@ public class CollectionTagRepository : ICollectionTagRepository
.SingleOrDefaultAsync();
}
- public async Task<IEnumerable<CollectionTagDto>> SearchTagDtosAsync(string searchQuery)
+ public async Task<IEnumerable<CollectionTagDto>> SearchTagDtosAsync(string searchQuery, int userId)
{
+ var userRating = (await _context.AppUser.SingleAsync(u => u.Id == userId)).AgeRestriction;
return await _context.CollectionTag
.Where(s => EF.Functions.Like(s.Title, $"%{searchQuery}%")
|| EF.Functions.Like(s.NormalizedTitle, $"%{searchQuery}%"))
+ .RestrictAgainstAgeRestriction(userRating)
.OrderBy(s => s.Title)
.AsNoTracking()
.OrderBy(c => c.NormalizedTitle)
diff --git a/API/Data/Repositories/ReadingListRepository.cs b/API/Data/Repositories/ReadingListRepository.cs
index 6fde82929..3401205d1 100644
--- a/API/Data/Repositories/ReadingListRepository.cs
+++ b/API/Data/Repositories/ReadingListRepository.cs
@@ -23,6 +23,7 @@ public interface IReadingListRepository
Task<IEnumerable<ReadingListDto>> GetReadingListDtosForSeriesAndUserAsync(int userId, int seriesId,
bool includePromoted);
void Remove(ReadingListItem item);
+ void Add(ReadingList list);
void BulkRemove(IEnumerable<ReadingListItem> items);
void Update(ReadingList list);
Task<int> Count();
@@ -46,6 +47,11 @@ public class ReadingListRepository : IReadingListRepository
_context.Entry(list).State = EntityState.Modified;
}
+ public void Add(ReadingList list)
+ {
+ _context.Add(list);
+ }
+
public async Task<int> Count()
{
return await _context.ReadingList.CountAsync();
@@ -82,8 +88,10 @@ public class ReadingListRepository : IReadingListRepository
public async Task<PagedList<ReadingListDto>> GetReadingListDtosForUserAsync(int userId, bool includePromoted, UserParams userParams)
{
+ var userAgeRating = (await _context.AppUser.SingleAsync(u => u.Id == userId)).AgeRestriction;
var query = _context.ReadingList
.Where(l => l.AppUserId == userId || (includePromoted && l.Promoted ))
+ .Where(l => l.AgeRating >= userAgeRating)
.OrderBy(l => l.LastModified)
.ProjectTo<ReadingListDto>(_mapper.ConfigurationProvider)
.AsNoTracking();
@@ -97,7 +105,7 @@ public class ReadingListRepository : IReadingListRepository
.Where(l => l.AppUserId == userId || (includePromoted && l.Promoted ))
.Where(l => l.Items.Any(i => i.SeriesId == seriesId))
.AsSplitQuery()
- .OrderBy(l => l.LastModified)
+ .OrderBy(l => l.Title)
.ProjectTo<ReadingListDto>(_mapper.ConfigurationProvider)
.AsNoTracking();
diff --git a/API/Data/Repositories/SeriesRepository.cs b/API/Data/Repositories/SeriesRepository.cs
index dbb78641a..6edb4caf7 100644
--- a/API/Data/Repositories/SeriesRepository.cs
+++ b/API/Data/Repositories/SeriesRepository.cs
@@ -51,6 +51,7 @@ internal class RecentlyAddedSeries
public string ChapterTitle { get; init; }
public bool IsSpecial { get; init; }
public int VolumeNumber { get; init; }
+ public AgeRating AgeRating { get; init; }
}
public interface ISeriesRepository
@@ -118,11 +119,11 @@ public interface ISeriesRepository
Task<SeriesDto> GetSeriesForMangaFile(int mangaFileId, int userId);
Task<SeriesDto> GetSeriesForChapter(int chapterId, int userId);
Task<PagedList<SeriesDto>> GetWantToReadForUserAsync(int userId, UserParams userParams, FilterDto filter);
- Task<int> GetSeriesIdByFolder(string folder);
Task<Series> GetSeriesByFolderPath(string folder, SeriesIncludes includes = SeriesIncludes.None);
Task<Series> GetFullSeriesByAnyName(string seriesName, string localizedName, int libraryId, MangaFormat format, bool withFullIncludes = true);
Task<List<Series>> RemoveSeriesNotInList(IList<ParsedSeries> seenSeries, int libraryId);
Task<IDictionary<string, IList<SeriesModified>>> GetFolderPathMap(int libraryId);
+ Task<AgeRating> GetMaxAgeRatingFromSeriesAsync(IEnumerable<int> seriesIds);
}
public class SeriesRepository : ISeriesRepository
@@ -307,9 +308,11 @@ public class SeriesRepository : ISeriesRepository
const int maxRecords = 15;
var result = new SearchResultGroupDto();
var searchQueryNormalized = Services.Tasks.Scanner.Parser.Parser.Normalize(searchQuery);
+ var userRating = await GetUserAgeRestriction(userId);
var seriesIds = _context.Series
.Where(s => libraryIds.Contains(s.LibraryId))
+ .RestrictAgainstAgeRestriction(userRating)
.Select(s => s.Id)
.ToList();
@@ -333,6 +336,7 @@ public class SeriesRepository : ISeriesRepository
|| EF.Functions.Like(s.LocalizedName, $"%{searchQuery}%")
|| EF.Functions.Like(s.NormalizedName, $"%{searchQueryNormalized}%")
|| (hasYearInQuery && s.Metadata.ReleaseYear == yearComparison))
+ .RestrictAgainstAgeRestriction(userRating)
.Include(s => s.Library)
.OrderBy(s => s.SortName)
.AsNoTracking()
@@ -341,19 +345,20 @@ public class SeriesRepository : ISeriesRepository
.ProjectTo<SearchResultDto>(_mapper.ConfigurationProvider)
.AsEnumerable();
-
result.ReadingLists = await _context.ReadingList
.Where(rl => rl.AppUserId == userId || rl.Promoted)
.Where(rl => EF.Functions.Like(rl.Title, $"%{searchQuery}%"))
+ .RestrictAgainstAgeRestriction(userRating)
.AsSplitQuery()
.Take(maxRecords)
.ProjectTo<ReadingListDto>(_mapper.ConfigurationProvider)
.ToListAsync();
result.Collections = await _context.CollectionTag
- .Where(s => EF.Functions.Like(s.Title, $"%{searchQuery}%")
- || EF.Functions.Like(s.NormalizedTitle, $"%{searchQueryNormalized}%"))
- .Where(s => s.Promoted || isAdmin)
+ .Where(c => EF.Functions.Like(c.Title, $"%{searchQuery}%")
+ || EF.Functions.Like(c.NormalizedTitle, $"%{searchQueryNormalized}%"))
+ .Where(c => c.Promoted || isAdmin)
+ .RestrictAgainstAgeRestriction(userRating)
.OrderBy(s => s.Title)
.AsNoTracking()
.AsSplitQuery()
@@ -392,7 +397,7 @@ public class SeriesRepository : ISeriesRepository
.ToListAsync();
var fileIds = _context.Series
- .Where(s => libraryIds.Contains(s.LibraryId))
+ .Where(s => seriesIds.Contains(s.Id))
.AsSplitQuery()
.SelectMany(s => s.Volumes)
.SelectMany(v => v.Chapters)
@@ -735,6 +740,8 @@ public class SeriesRepository : ISeriesRepository
private async Task<IQueryable<Series>> CreateFilteredSearchQueryable(int userId, int libraryId, FilterDto filter)
{
var userLibraries = await GetUserLibraries(libraryId, userId);
+ var userRating = await GetUserAgeRestriction(userId);
+
var formats = ExtractFilters(libraryId, userId, filter, ref userLibraries,
out var allPeopleIds, out var hasPeopleFilter, out var hasGenresFilter,
out var hasCollectionTagFilter, out var hasRatingFilter, out var hasProgressFilter,
@@ -759,8 +766,13 @@ public class SeriesRepository : ISeriesRepository
.Where(s => !hasSeriesNameFilter ||
EF.Functions.Like(s.Name, $"%{filter.SeriesNameQuery}%")
|| EF.Functions.Like(s.OriginalName, $"%{filter.SeriesNameQuery}%")
- || EF.Functions.Like(s.LocalizedName, $"%{filter.SeriesNameQuery}%"))
- .AsNoTracking();
+ || EF.Functions.Like(s.LocalizedName, $"%{filter.SeriesNameQuery}%"));
+ if (userRating != AgeRating.NotApplicable)
+ {
+ query = query.RestrictAgainstAgeRestriction(userRating);
+ }
+
+ query = query.AsNoTracking();
// If no sort options, default to using SortName
filter.SortOptions ??= new SortOptions()
@@ -1033,7 +1045,10 @@ public class SeriesRepository : ISeriesRepository
{
var seriesMap = new Dictionary<string, GroupedSeriesDto>();
var index = 0;
- foreach (var item in await GetRecentlyAddedChaptersQuery(userId))
+ var userRating = await GetUserAgeRestriction(userId);
+
+ var items = (await GetRecentlyAddedChaptersQuery(userId));
+ foreach (var item in items.Where(c => c.AgeRating <= userRating))
{
if (seriesMap.Keys.Count == pageSize) break;
@@ -1061,11 +1076,19 @@ public class SeriesRepository : ISeriesRepository
return seriesMap.Values.AsEnumerable();
}
+ private async Task<AgeRating> GetUserAgeRestriction(int userId)
+ {
+ return (await _context.AppUser.SingleAsync(u => u.Id == userId)).AgeRestriction;
+ }
+
public async Task<IEnumerable<SeriesDto>> GetSeriesForRelationKind(int userId, int seriesId, RelationKind kind)
{
var libraryIds = GetLibraryIdsForUser(userId);
+ var userRating = await GetUserAgeRestriction(userId);
+
var usersSeriesIds = _context.Series
.Where(s => libraryIds.Contains(s.LibraryId))
+ .RestrictAgainstAgeRestriction(userRating)
.Select(s => s.Id);
var targetSeries = _context.SeriesRelation
@@ -1078,6 +1101,7 @@ public class SeriesRepository : ISeriesRepository
return await _context.Series
.Where(s => targetSeries.Contains(s.Id))
+ .RestrictAgainstAgeRestriction(userRating)
.AsSplitQuery()
.AsNoTracking()
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
@@ -1128,6 +1152,8 @@ public class SeriesRepository : ISeriesRepository
public async Task<SeriesDto> GetSeriesForMangaFile(int mangaFileId, int userId)
{
var libraryIds = GetLibraryIdsForUser(userId);
+ var userRating = await GetUserAgeRestriction(userId);
+
return await _context.MangaFile
.Where(m => m.Id == mangaFileId)
.AsSplitQuery()
@@ -1135,6 +1161,7 @@ public class SeriesRepository : ISeriesRepository
.Select(c => c.Volume)
.Select(v => v.Series)
.Where(s => libraryIds.Contains(s.LibraryId))
+ .RestrictAgainstAgeRestriction(userRating)
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
.SingleOrDefaultAsync();
}
@@ -1142,31 +1169,18 @@ public class SeriesRepository : ISeriesRepository
public async Task<SeriesDto> GetSeriesForChapter(int chapterId, int userId)
{
var libraryIds = GetLibraryIdsForUser(userId);
+ var userRating = await GetUserAgeRestriction(userId);
return await _context.Chapter
.Where(m => m.Id == chapterId)
.AsSplitQuery()
.Select(c => c.Volume)
.Select(v => v.Series)
.Where(s => libraryIds.Contains(s.LibraryId))
+ .RestrictAgainstAgeRestriction(userRating)
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
.SingleOrDefaultAsync();
}
- /// <summary>
- /// Given a folder path return a Series with the <see cref="Series.FolderPath"/> that matches.
- /// </summary>
- /// <remarks>This will apply normalization on the path.</remarks>
- /// <param name="folder"></param>
- /// <returns></returns>
- public async Task<int> GetSeriesIdByFolder(string folder)
- {
- var normalized = Services.Tasks.Scanner.Parser.Parser.NormalizePath(folder);
- var series = await _context.Series
- .Where(s => s.FolderPath.Equals(normalized))
- .SingleOrDefaultAsync();
- return series?.Id ?? 0;
- }
-
/// <summary>
/// Return a Series by Folder path. Null if not found.
/// </summary>
@@ -1368,21 +1382,22 @@ public class SeriesRepository : ISeriesRepository
{
var libraryIds = GetLibraryIdsForUser(userId);
var usersSeriesIds = GetSeriesIdsForLibraryIds(libraryIds);
+ var userRating = await GetUserAgeRestriction(userId);
return new RelatedSeriesDto()
{
SourceSeriesId = seriesId,
- Adaptations = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.Adaptation),
- Characters = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.Character),
- Prequels = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.Prequel),
- Sequels = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.Sequel),
- Contains = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.Contains),
- SideStories = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.SideStory),
- SpinOffs = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.SpinOff),
- Others = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.Other),
- AlternativeSettings = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.AlternativeSetting),
- AlternativeVersions = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.AlternativeVersion),
- Doujinshis = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.Doujinshi),
+ Adaptations = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.Adaptation, userRating),
+ Characters = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.Character, userRating),
+ Prequels = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.Prequel, userRating),
+ Sequels = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.Sequel, userRating),
+ Contains = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.Contains, userRating),
+ SideStories = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.SideStory, userRating),
+ SpinOffs = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.SpinOff, userRating),
+ Others = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.Other, userRating),
+ AlternativeSettings = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.AlternativeSetting, userRating),
+ AlternativeVersions = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.AlternativeVersion, userRating),
+ Doujinshis = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.Doujinshi, userRating),
Parent = await _context.Series
.SelectMany(s =>
s.RelationOf.Where(r => r.TargetSeriesId == seriesId
@@ -1390,6 +1405,7 @@ public class SeriesRepository : ISeriesRepository
&& r.RelationKind != RelationKind.Prequel
&& r.RelationKind != RelationKind.Sequel)
.Select(sr => sr.Series))
+ .RestrictAgainstAgeRestriction(userRating)
.AsSplitQuery()
.AsNoTracking()
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
@@ -1404,11 +1420,12 @@ public class SeriesRepository : ISeriesRepository
.Select(s => s.Id);
}
- private async Task<IEnumerable<SeriesDto>> GetRelatedSeriesQuery(int seriesId, IEnumerable<int> usersSeriesIds, RelationKind kind)
+ private async Task<IEnumerable<SeriesDto>> GetRelatedSeriesQuery(int seriesId, IEnumerable<int> usersSeriesIds, RelationKind kind, AgeRating userRating)
{
return await _context.Series.SelectMany(s =>
s.Relations.Where(sr => sr.RelationKind == kind && sr.SeriesId == seriesId && usersSeriesIds.Contains(sr.TargetSeriesId))
.Select(sr => sr.TargetSeries))
+ .RestrictAgainstAgeRestriction(userRating)
.AsSplitQuery()
.AsNoTracking()
.ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
@@ -1417,16 +1434,15 @@ public class SeriesRepository : ISeriesRepository
private async Task<IEnumerable<RecentlyAddedSeries>> GetRecentlyAddedChaptersQuery(int userId)
{
- var libraries = await _context.AppUser
+ var libraryIds = await _context.AppUser
.Where(u => u.Id == userId)
.SelectMany(u => u.Libraries.Select(l => new {LibraryId = l.Id, LibraryType = l.Type}))
+ .Select(l => l.LibraryId)
.ToListAsync();
- var libraryIds = libraries.Select(l => l.LibraryId).ToList();
var withinLastWeek = DateTime.Now - TimeSpan.FromDays(12);
- var ret = _context.Chapter
- .Where(c => c.Created >= withinLastWeek)
- .AsNoTracking()
+ return _context.Chapter
+ .Where(c => c.Created >= withinLastWeek).AsNoTracking()
.Include(c => c.Volume)
.ThenInclude(v => v.Series)
.ThenInclude(s => s.Library)
@@ -1445,12 +1461,12 @@ public class SeriesRepository : ISeriesRepository
ChapterRange = c.Range,
IsSpecial = c.IsSpecial,
VolumeNumber = c.Volume.Number,
- ChapterTitle = c.Title
+ ChapterTitle = c.Title,
+ AgeRating = c.Volume.Series.Metadata.AgeRating
})
.AsSplitQuery()
.Where(c => c.Created >= withinLastWeek && libraryIds.Contains(c.LibraryId))
.AsEnumerable();
- return ret;
}
public async Task<PagedList<SeriesDto>> GetWantToReadForUserAsync(int userId, UserParams userParams, FilterDto filter)
@@ -1503,6 +1519,21 @@ public class SeriesRepository : ISeriesRepository
return map;
}
+ /// <summary>
+ /// Returns the highest Age Rating for a list of Series
+ /// </summary>
+ /// <param name="seriesIds"></param>
+ /// <returns></returns>
+ public async Task<AgeRating> GetMaxAgeRatingFromSeriesAsync(IEnumerable<int> seriesIds)
+ {
+ return await _context.Series
+ .Where(s => seriesIds.Contains(s.Id))
+ .Include(s => s.Metadata)
+ .Select(s => s.Metadata.AgeRating)
+ .OrderBy(s => s)
+ .LastOrDefaultAsync();
+ }
+
private static IQueryable<Series> AddIncludesToQuery(IQueryable<Series> query, SeriesIncludes includeFlags)
{
if (includeFlags.HasFlag(SeriesIncludes.Library))
diff --git a/API/Data/Repositories/UserRepository.cs b/API/Data/Repositories/UserRepository.cs
index 44a01066a..62d802f3a 100644
--- a/API/Data/Repositories/UserRepository.cs
+++ b/API/Data/Repositories/UserRepository.cs
@@ -396,6 +396,7 @@ public class UserRepository : IUserRepository
Created = u.Created,
LastActive = u.LastActive,
Roles = u.UserRoles.Select(r => r.Role.Name).ToList(),
+ AgeRestriction = u.AgeRestriction,
Libraries = u.Libraries.Select(l => new LibraryDto
{
Name = l.Name,
@@ -429,6 +430,7 @@ public class UserRepository : IUserRepository
Created = u.Created,
LastActive = u.LastActive,
Roles = u.UserRoles.Select(r => r.Role.Name).ToList(),
+ AgeRestriction = u.AgeRestriction,
Libraries = u.Libraries.Select(l => new LibraryDto
{
Name = l.Name,
diff --git a/API/Entities/AppUser.cs b/API/Entities/AppUser.cs
index cf8ab3304..53cdefce6 100644
--- a/API/Entities/AppUser.cs
+++ b/API/Entities/AppUser.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+using API.Entities.Enums;
using API.Entities.Interfaces;
using Microsoft.AspNetCore.Identity;
@@ -40,7 +41,10 @@ public class AppUser : IdentityUser<int>, IHasConcurrencyToken
/// The confirmation token for the user (invite). This will be set to null after the user confirms.
/// </summary>
public string ConfirmationToken { get; set; }
-
+ /// <summary>
+ /// The highest age rating the user has access to. Not applicable for admins
+ /// </summary>
+ public AgeRating AgeRestriction { get; set; } = AgeRating.NotApplicable;
/// <inheritdoc />
[ConcurrencyCheck]
diff --git a/API/Entities/Enums/AgeRating.cs b/API/Entities/Enums/AgeRating.cs
index 82dbef7ae..9eefb9fa7 100644
--- a/API/Entities/Enums/AgeRating.cs
+++ b/API/Entities/Enums/AgeRating.cs
@@ -8,6 +8,11 @@ namespace API.Entities.Enums;
/// <remarks>Based on ComicInfo.xml v2.1 https://github.com/anansi-project/comicinfo/blob/main/drafts/v2.1/ComicInfo.xsd</remarks>
public enum AgeRating
{
+ /// <summary>
+ /// This is for Age Restriction for Restricted Profiles
+ /// </summary>
+ [Description("Not Applicable")]
+ NotApplicable = -1,
[Description("Unknown")]
Unknown = 0,
[Description("Rating Pending")]
diff --git a/API/Entities/ReadingList.cs b/API/Entities/ReadingList.cs
index 8a4ecf96b..6712fe923 100644
--- a/API/Entities/ReadingList.cs
+++ b/API/Entities/ReadingList.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using API.Entities.Enums;
using API.Entities.Interfaces;
namespace API.Entities;
@@ -27,6 +28,12 @@ public class ReadingList : IEntityDate
public string CoverImage { get; set; }
public bool CoverImageLocked { get; set; }
+ /// <summary>
+ /// The highest age rating from all Series within the reading list
+ /// </summary>
+ /// <remarks>Introduced in v0.6</remarks>
+ public AgeRating AgeRating { get; set; } = AgeRating.Unknown;
+
public ICollection<ReadingListItem> Items { get; set; }
public DateTime Created { get; set; }
public DateTime LastModified { get; set; }
diff --git a/API/Extensions/QueryableExtensions.cs b/API/Extensions/QueryableExtensions.cs
new file mode 100644
index 000000000..d92406613
--- /dev/null
+++ b/API/Extensions/QueryableExtensions.cs
@@ -0,0 +1,23 @@
+using System.Linq;
+using API.Entities;
+using API.Entities.Enums;
+
+namespace API.Extensions;
+
+public static class QueryableExtensions
+{
+ public static IQueryable<Series> RestrictAgainstAgeRestriction(this IQueryable<Series> queryable, AgeRating rating)
+ {
+ return queryable.Where(s => rating == AgeRating.NotApplicable || s.Metadata.AgeRating <= rating);
+ }
+
+ public static IQueryable<CollectionTag> RestrictAgainstAgeRestriction(this IQueryable<CollectionTag> queryable, AgeRating rating)
+ {
+ return queryable.Where(c => c.SeriesMetadatas.All(sm => sm.AgeRating <= rating));
+ }
+
+ public static IQueryable<ReadingList> RestrictAgainstAgeRestriction(this IQueryable<ReadingList> queryable, AgeRating rating)
+ {
+ return queryable.Where(rl => rl.AgeRating <= rating);
+ }
+}
diff --git a/API/Services/AccountService.cs b/API/Services/AccountService.cs
index 1eb50f281..0d8bed66c 100644
--- a/API/Services/AccountService.cs
+++ b/API/Services/AccountService.cs
@@ -118,4 +118,15 @@ public class AccountService : IAccountService
return roles.Contains(PolicyConstants.DownloadRole) || roles.Contains(PolicyConstants.AdminRole);
}
+ /// <summary>
+ /// Does the user have Change Restriction permission or admin rights
+ /// </summary>
+ /// <param name="user"></param>
+ /// <returns></returns>
+ public async Task<bool> HasChangeRestrictionRole(AppUser user)
+ {
+ var roles = await _userManager.GetRolesAsync(user);
+ return roles.Contains(PolicyConstants.ChangePasswordRole) || roles.Contains(PolicyConstants.AdminRole);
+ }
+
}
diff --git a/API/Services/ReadingListService.cs b/API/Services/ReadingListService.cs
index 60314e3a9..55c842252 100644
--- a/API/Services/ReadingListService.cs
+++ b/API/Services/ReadingListService.cs
@@ -17,7 +17,7 @@ public interface IReadingListService
Task<bool> DeleteReadingListItem(UpdateReadingListPosition dto);
Task<AppUser?> UserHasReadingListAccess(int readingListId, string username);
Task<bool> DeleteReadingList(int readingListId, AppUser user);
-
+ Task CalculateReadingListAgeRating(ReadingList readingList);
Task<bool> AddChaptersToReadingList(int seriesId, IList<int> chapterIds,
ReadingList readingList);
}
@@ -41,7 +41,7 @@ public class ReadingListService : IReadingListService
/// <summary>
- /// Removes all entries that are fully read from the reading list
+ /// Removes all entries that are fully read from the reading list. This commits
/// </summary>
/// <remarks>If called from API layer, expected for <see cref="UserHasReadingListAccess"/> to be called beforehand</remarks>
/// <param name="readingListId">Reading List Id</param>
@@ -62,10 +62,12 @@ public class ReadingListService : IReadingListService
itemIdsToRemove.Contains(r.Id));
_unitOfWork.ReadingListRepository.BulkRemove(listItems);
+ var readingList = await _unitOfWork.ReadingListRepository.GetReadingListByIdAsync(readingListId);
+ await CalculateReadingListAgeRating(readingList);
+
if (!_unitOfWork.HasChanges()) return true;
- await _unitOfWork.CommitAsync();
- return true;
+ return await _unitOfWork.CommitAsync();
}
catch
{
@@ -97,6 +99,11 @@ public class ReadingListService : IReadingListService
return await _unitOfWork.CommitAsync();
}
+ /// <summary>
+ /// Removes a certain reading list item from a reading list
+ /// </summary>
+ /// <param name="dto">Only ReadingListId and ReadingListItemId are used</param>
+ /// <returns></returns>
public async Task<bool> DeleteReadingListItem(UpdateReadingListPosition dto)
{
var readingList = await _unitOfWork.ReadingListRepository.GetReadingListByIdAsync(dto.ReadingListId);
@@ -109,11 +116,34 @@ public class ReadingListService : IReadingListService
index++;
}
+ await CalculateReadingListAgeRating(readingList);
+
if (!_unitOfWork.HasChanges()) return true;
return await _unitOfWork.CommitAsync();
}
+ /// <summary>
+ /// Calculates the highest Age Rating from each Reading List Item
+ /// </summary>
+ /// <param name="readingList"></param>
+ public async Task CalculateReadingListAgeRating(ReadingList readingList)
+ {
+ await CalculateReadingListAgeRating(readingList, readingList.Items.Select(i => i.SeriesId));
+ }
+
+ /// <summary>
+ /// Calculates the highest Age Rating from each Reading List Item
+ /// </summary>
+ /// <remarks>This method is used when the ReadingList doesn't have items yet</remarks>
+ /// <param name="readingList"></param>
+ /// <param name="seriesIds">The series ids of all the reading list items</param>
+ private async Task CalculateReadingListAgeRating(ReadingList readingList, IEnumerable<int> seriesIds)
+ {
+ var ageRating = await _unitOfWork.SeriesRepository.GetMaxAgeRatingFromSeriesAsync(seriesIds);
+ readingList.AgeRating = ageRating;
+ }
+
/// <summary>
/// Validates the user has access to the reading list to perform actions on it
/// </summary>
@@ -167,16 +197,18 @@ public class ReadingListService : IReadingListService
var existingChapterExists = readingList.Items.Select(rli => rli.ChapterId).ToHashSet();
var chaptersForSeries = (await _unitOfWork.ChapterRepository.GetChaptersByIdsAsync(chapterIds))
.OrderBy(c => Tasks.Scanner.Parser.Parser.MinNumberFromRange(c.Volume.Name))
- .ThenBy(x => double.Parse(x.Number), _chapterSortComparerForInChapterSorting);
+ .ThenBy(x => double.Parse(x.Number), _chapterSortComparerForInChapterSorting)
+ .ToList();
var index = lastOrder + 1;
- foreach (var chapter in chaptersForSeries)
+ foreach (var chapter in chaptersForSeries.Where(chapter => !existingChapterExists.Contains(chapter.Id)))
{
- if (existingChapterExists.Contains(chapter.Id)) continue;
readingList.Items.Add(DbFactory.ReadingListItem(index, seriesId, chapter.VolumeId, chapter.Id));
index += 1;
}
+ await CalculateReadingListAgeRating(readingList, new []{ seriesId });
+
return index > lastOrder + 1;
}
}
diff --git a/API/Services/SeriesService.cs b/API/Services/SeriesService.cs
index 963c9a472..27f4cbc55 100644
--- a/API/Services/SeriesService.cs
+++ b/API/Services/SeriesService.cs
@@ -474,6 +474,14 @@ public class SeriesService : ISeriesService
if (!libraryIds.Contains(series.LibraryId))
throw new UnauthorizedAccessException("User does not have access to the library this series belongs to");
+ var user = await _unitOfWork.UserRepository.GetUserByIdAsync(userId);
+ if (user.AgeRestriction != AgeRating.NotApplicable)
+ {
+ var seriesMetadata = await _unitOfWork.SeriesRepository.GetSeriesMetadata(seriesId);
+ if (seriesMetadata.AgeRating > user.AgeRestriction)
+ throw new UnauthorizedAccessException("User is not allowed to view this series due to age restrictions");
+ }
+
var libraryType = await _unitOfWork.LibraryRepository.GetLibraryTypeAsync(series.LibraryId);
var volumes = (await _unitOfWork.VolumeRepository.GetVolumesDtoAsync(seriesId, userId))
.OrderBy(v => Tasks.Scanner.Parser.Parser.MinNumberFromRange(v.Name))
diff --git a/API/Services/Tasks/Scanner/ParseScannedFiles.cs b/API/Services/Tasks/Scanner/ParseScannedFiles.cs
index 45e598957..d36fb3cff 100644
--- a/API/Services/Tasks/Scanner/ParseScannedFiles.cs
+++ b/API/Services/Tasks/Scanner/ParseScannedFiles.cs
@@ -84,7 +84,6 @@ public class ParseScannedFiles
if (scanDirectoryByDirectory)
{
// This is used in library scan, so we should check first for a ignore file and use that here as well
- // TODO: We need to calculate all folders till library root and see if any kavitaignores
var potentialIgnoreFile = _directoryService.FileSystem.Path.Join(folderPath, DirectoryService.KavitaIgnoreFile);
var matcher = _directoryService.CreateMatcherFromFile(potentialIgnoreFile);
var directories = _directoryService.GetDirectories(folderPath, matcher).ToList();
diff --git a/API/Startup.cs b/API/Startup.cs
index 2da14d07f..ed7181816 100644
--- a/API/Startup.cs
+++ b/API/Startup.cs
@@ -184,16 +184,20 @@ public class Startup
var userManager = serviceProvider.GetRequiredService<UserManager<AppUser>>();
var themeService = serviceProvider.GetRequiredService<IThemeService>();
var dataContext = serviceProvider.GetRequiredService<DataContext>();
+ var readingListService = serviceProvider.GetRequiredService<IReadingListService>();
// Only run this if we are upgrading
await MigrateChangePasswordRoles.Migrate(unitOfWork, userManager);
-
await MigrateRemoveExtraThemes.Migrate(unitOfWork, themeService);
// only needed for v0.5.4 and v0.6.0
await MigrateNormalizedEverything.Migrate(unitOfWork, dataContext, logger);
+ // v0.6.0
+ await MigrateChangeRestrictionRoles.Migrate(unitOfWork, userManager, logger);
+ await MigrateReadingListAgeRating.Migrate(unitOfWork, dataContext, readingListService, logger);
+
// Update the version in the DB after all migrations are run
var installVersion = await unitOfWork.SettingsRepository.GetSettingAsync(ServerSettingKey.InstallVersion);
installVersion.Value = BuildInfo.Version.ToString();
diff --git a/TestData b/TestData
new file mode 160000
index 000000000..4f5750025
--- /dev/null
+++ b/TestData
@@ -0,0 +1 @@
+Subproject commit 4f5750025a1c0b48cd72eaa6f1b61642c41f147f
diff --git a/UI/Web/src/app/_models/member.ts b/UI/Web/src/app/_models/member.ts
index 874dba535..eb584b340 100644
--- a/UI/Web/src/app/_models/member.ts
+++ b/UI/Web/src/app/_models/member.ts
@@ -1,4 +1,5 @@
import { Library } from './library';
+import { AgeRating } from './metadata/age-rating';
export interface Member {
id: number;
@@ -6,7 +7,10 @@ export interface Member {
email: string;
lastActive: string; // datetime
created: string; // datetime
- //isAdmin: boolean;
roles: string[];
libraries: Library[];
+ /**
+ * If not applicable, will store a -1
+ */
+ ageRestriction: AgeRating;
}
\ No newline at end of file
diff --git a/UI/Web/src/app/_models/metadata/age-rating.ts b/UI/Web/src/app/_models/metadata/age-rating.ts
index d44a8e250..cbb2e86a5 100644
--- a/UI/Web/src/app/_models/metadata/age-rating.ts
+++ b/UI/Web/src/app/_models/metadata/age-rating.ts
@@ -1,4 +1,8 @@
export enum AgeRating {
+ /**
+ * This is not a valid state for Series/Chapters, but used for Restricted Profiles
+ */
+ NotApplicable = -1,
Unknown = 0,
AdultsOnly = 1,
EarlyChildhood = 2,
diff --git a/UI/Web/src/app/_models/user.ts b/UI/Web/src/app/_models/user.ts
index ba26206dd..1271b1a17 100644
--- a/UI/Web/src/app/_models/user.ts
+++ b/UI/Web/src/app/_models/user.ts
@@ -1,3 +1,4 @@
+import { AgeRating } from './metadata/age-rating';
import { Preferences } from './preferences/preferences';
// This interface is only used for login and storing/retreiving JWT from local storage
@@ -9,4 +10,5 @@ export interface User {
preferences: Preferences;
apiKey: string;
email: string;
+ ageRestriction: AgeRating;
}
\ No newline at end of file
diff --git a/UI/Web/src/app/_services/account.service.ts b/UI/Web/src/app/_services/account.service.ts
index 71a8b1489..5990fe6d4 100644
--- a/UI/Web/src/app/_services/account.service.ts
+++ b/UI/Web/src/app/_services/account.service.ts
@@ -10,8 +10,16 @@ import { EVENTS, MessageHubService } from './message-hub.service';
import { ThemeService } from './theme.service';
import { InviteUserResponse } from '../_models/invite-user-response';
import { UserUpdateEvent } from '../_models/events/user-update-event';
-import { DeviceService } from './device.service';
import { UpdateEmailResponse } from '../_models/email/update-email-response';
+import { AgeRating } from '../_models/metadata/age-rating';
+
+export enum Role {
+ Admin = 'Admin',
+ ChangePassword = 'Change Password',
+ Bookmark = 'Bookmark',
+ Download = 'Download',
+ ChangeRestriction = 'Change Restriction'
+}
@Injectable({
providedIn: 'root'
@@ -49,19 +57,23 @@ export class AccountService implements OnDestroy {
}
hasAdminRole(user: User) {
- return user && user.roles.includes('Admin');
+ return user && user.roles.includes(Role.Admin);
}
hasChangePasswordRole(user: User) {
- return user && user.roles.includes('Change Password');
+ return user && user.roles.includes(Role.ChangePassword);
+ }
+
+ hasChangeAgeRestrictionRole(user: User) {
+ return user && user.roles.includes(Role.ChangeRestriction);
}
hasDownloadRole(user: User) {
- return user && user.roles.includes('Download');
+ return user && user.roles.includes(Role.Download);
}
hasBookmarkRole(user: User) {
- return user && user.roles.includes('Bookmark');
+ return user && user.roles.includes(Role.Bookmark);
}
getRoles() {
@@ -149,7 +161,7 @@ export class AccountService implements OnDestroy {
return this.httpClient.post<string>(this.baseUrl + 'account/resend-confirmation-email?userId=' + userId, {}, {responseType: 'text' as 'json'});
}
- inviteUser(model: {email: string, roles: Array<string>, libraries: Array<number>}) {
+ inviteUser(model: {email: string, roles: Array<string>, libraries: Array<number>, ageRestriction: AgeRating}) {
return this.httpClient.post<InviteUserResponse>(this.baseUrl + 'account/invite', model);
}
@@ -186,7 +198,7 @@ export class AccountService implements OnDestroy {
return this.httpClient.post(this.baseUrl + 'account/reset-password', {username, password, oldPassword}, {responseType: 'json' as 'text'});
}
- update(model: {email: string, roles: Array<string>, libraries: Array<number>, userId: number}) {
+ update(model: {email: string, roles: Array<string>, libraries: Array<number>, userId: number, ageRestriction: AgeRating}) {
return this.httpClient.post(this.baseUrl + 'account/update', model);
}
@@ -194,6 +206,10 @@ export class AccountService implements OnDestroy {
return this.httpClient.post<UpdateEmailResponse>(this.baseUrl + 'account/update/email', {email});
}
+ updateAgeRestriction(ageRating: AgeRating) {
+ return this.httpClient.post(this.baseUrl + 'account/update/age-restriction', {ageRating});
+ }
+
/**
* This will get latest preferences for a user and cache them into user store
* @returns
diff --git a/UI/Web/src/app/_services/library.service.ts b/UI/Web/src/app/_services/library.service.ts
index 5aac12cfd..00619d5bd 100644
--- a/UI/Web/src/app/_services/library.service.ts
+++ b/UI/Web/src/app/_services/library.service.ts
@@ -113,12 +113,4 @@ export class LibraryService {
return this.libraryTypes[libraryId];
}));
}
-
- search(term: string) {
- if (term === '') {
- return of(new SearchResultGroup());
- }
- return this.httpClient.get<SearchResultGroup>(this.baseUrl + 'library/search?queryString=' + encodeURIComponent(term));
- }
-
}
diff --git a/UI/Web/src/app/_services/search.service.ts b/UI/Web/src/app/_services/search.service.ts
new file mode 100644
index 000000000..fa989fa35
--- /dev/null
+++ b/UI/Web/src/app/_services/search.service.ts
@@ -0,0 +1,31 @@
+import { HttpClient } from '@angular/common/http';
+import { Injectable } from '@angular/core';
+import { of } from 'rxjs';
+import { environment } from 'src/environments/environment';
+import { SearchResultGroup } from '../_models/search/search-result-group';
+import { Series } from '../_models/series';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class SearchService {
+
+ baseUrl = environment.apiUrl;
+
+ constructor(private httpClient: HttpClient) { }
+
+ search(term: string) {
+ if (term === '') {
+ return of(new SearchResultGroup());
+ }
+ return this.httpClient.get<SearchResultGroup>(this.baseUrl + 'search/search?queryString=' + encodeURIComponent(term));
+ }
+
+ getSeriesForMangaFile(mangaFileId: number) {
+ return this.httpClient.get<Series | null>(this.baseUrl + 'search/series-for-mangafile?mangaFileId=' + mangaFileId);
+ }
+
+ getSeriesForChapter(chapterId: number) {
+ return this.httpClient.get<Series | null>(this.baseUrl + 'search/series-for-chapter?chapterId=' + chapterId);
+ }
+}
diff --git a/UI/Web/src/app/_services/series.service.ts b/UI/Web/src/app/_services/series.service.ts
index a5a5f26c7..9a7eb7677 100644
--- a/UI/Web/src/app/_services/series.service.ts
+++ b/UI/Web/src/app/_services/series.service.ts
@@ -78,14 +78,6 @@ export class SeriesService {
return this.httpClient.get<ChapterMetadata>(this.baseUrl + 'series/chapter-metadata?chapterId=' + chapterId);
}
- getSeriesForMangaFile(mangaFileId: number) {
- return this.httpClient.get<Series | null>(this.baseUrl + 'series/series-for-mangafile?mangaFileId=' + mangaFileId);
- }
-
- getSeriesForChapter(chapterId: number) {
- return this.httpClient.get<Series | null>(this.baseUrl + 'series/series-for-chapter?chapterId=' + chapterId);
- }
-
delete(seriesId: number) {
return this.httpClient.delete<boolean>(this.baseUrl + 'series/' + seriesId);
}
diff --git a/UI/Web/src/app/admin/edit-user/edit-user.component.html b/UI/Web/src/app/admin/edit-user/edit-user.component.html
index 433c200a5..4a5e8a600 100644
--- a/UI/Web/src/app/admin/edit-user/edit-user.component.html
+++ b/UI/Web/src/app/admin/edit-user/edit-user.component.html
@@ -1,58 +1,66 @@
-<div class="modal-header">
- <h4 class="modal-title" id="modal-basic-title">Edit {{member.username | sentenceCase}}</h4>
- <button type="button" class="btn-close" aria-label="Close" (click)="close()">
-
- </button>
-</div>
-<div class="modal-body">
+<div class="modal-container">
+ <div class="modal-header">
+ <h4 class="modal-title" id="modal-basic-title">Edit {{member.username | sentenceCase}}</h4>
+ <button type="button" class="btn-close" aria-label="Close" (click)="close()">
+
+ </button>
+ </div>
+ <div class="modal-body scrollable-modal">
- <form [formGroup]="userForm">
- <div class="row g-0">
- <div class="col-md-6 col-sm-12 pe-2">
- <div class="mb-3">
- <label for="username" class="form-label">Username</label>
- <input id="username" class="form-control" formControlName="username" type="text" [class.is-invalid]="userForm.get('username')?.invalid && userForm.get('username')?.touched">
- <div id="inviteForm-validations" class="invalid-feedback" *ngIf="userForm.dirty || userForm.touched">
- <div *ngIf="userForm.get('username')?.errors?.required">
- This field is required
+ <form [formGroup]="userForm">
+ <div class="row g-0">
+ <div class="col-md-6 col-sm-12 pe-2">
+ <div class="mb-3">
+ <label for="username" class="form-label">Username</label>
+ <input id="username" class="form-control" formControlName="username" type="text" [class.is-invalid]="userForm.get('username')?.invalid && userForm.get('username')?.touched">
+ <div id="inviteForm-validations" class="invalid-feedback" *ngIf="userForm.dirty || userForm.touched">
+ <div *ngIf="userForm.get('username')?.errors?.required">
+ This field is required
+ </div>
</div>
</div>
</div>
- </div>
- <div class="col-md-6 col-sm-12">
- <div class="mb-3" style="width:100%">
- <label for="email" class="form-label">Email</label>
- <input class="form-control" type="email" id="email" formControlName="email">
- <div id="inviteForm-validations" class="invalid-feedback" *ngIf="userForm.dirty || userForm.touched" [class.is-invalid]="userForm.get('email')?.invalid && userForm.get('email')?.touched">
- <div *ngIf="userForm.get('email')?.errors?.required">
- This field is required
- </div>
- <div *ngIf="userForm.get('email')?.errors?.email">
- This must be a valid email address
+ <div class="col-md-6 col-sm-12">
+ <div class="mb-3" style="width:100%">
+ <label for="email" class="form-label">Email</label>
+ <input class="form-control" type="email" id="email" formControlName="email">
+ <div id="inviteForm-validations" class="invalid-feedback" *ngIf="userForm.dirty || userForm.touched" [class.is-invalid]="userForm.get('email')?.invalid && userForm.get('email')?.touched">
+ <div *ngIf="userForm.get('email')?.errors?.required">
+ This field is required
+ </div>
+ <div *ngIf="userForm.get('email')?.errors?.email">
+ This must be a valid email address
+ </div>
</div>
</div>
</div>
</div>
- </div>
- <div class="row g-0">
- <div class="col-md-6">
- <app-role-selector (selected)="updateRoleSelection($event)" [allowAdmin]="true" [member]="member"></app-role-selector>
+ <div class="row g-0">
+ <div class="col-md-6">
+ <app-role-selector (selected)="updateRoleSelection($event)" [allowAdmin]="true" [member]="member"></app-role-selector>
+ </div>
+
+ <div class="col-md-6">
+ <app-library-selector (selected)="updateLibrarySelection($event)" [member]="member"></app-library-selector>
+ </div>
</div>
- <div class="col-md-6">
- <app-library-selector (selected)="updateLibrarySelection($event)" [member]="member"></app-library-selector>
+ <div class="row g-0">
+ <div class="col-md-12">
+ <app-restriction-selector (selected)="updateRestrictionSelection($event)" [isAdmin]="hasAdminRoleSelected" [member]="member"></app-restriction-selector>
+ </div>
</div>
- </div>
- </form>
+ </form>
-</div>
-<div class="modal-footer">
- <button type="button" class="btn btn-secondary" (click)="close()">
- Cancel
- </button>
- <button type="button" class="btn btn-primary" (click)="save()" [disabled]="isSaving || !userForm.valid">
- <span *ngIf="isSaving" class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
- <span>{{isSaving ? 'Saving...' : 'Update'}}</span>
- </button>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-secondary" (click)="close()">
+ Cancel
+ </button>
+ <button type="button" class="btn btn-primary" (click)="save()" [disabled]="isSaving || !userForm.valid">
+ <span *ngIf="isSaving" class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
+ <span>{{isSaving ? 'Saving...' : 'Update'}}</span>
+ </button>
+ </div>
</div>
diff --git a/UI/Web/src/app/admin/edit-user/edit-user.component.ts b/UI/Web/src/app/admin/edit-user/edit-user.component.ts
index 29b61caa5..c884f3d80 100644
--- a/UI/Web/src/app/admin/edit-user/edit-user.component.ts
+++ b/UI/Web/src/app/admin/edit-user/edit-user.component.ts
@@ -3,6 +3,7 @@ import { FormGroup, FormControl, Validators } from '@angular/forms';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Library } from 'src/app/_models/library';
import { Member } from 'src/app/_models/member';
+import { AgeRating } from 'src/app/_models/metadata/age-rating';
import { AccountService } from 'src/app/_services/account.service';
// TODO: Rename this to EditUserModal
@@ -17,6 +18,7 @@ export class EditUserComponent implements OnInit {
selectedRoles: Array<string> = [];
selectedLibraries: Array<number> = [];
+ selectedRating: AgeRating = AgeRating.NotApplicable;
isSaving: boolean = false;
userForm: FormGroup = new FormGroup({});
@@ -24,6 +26,7 @@ export class EditUserComponent implements OnInit {
public get email() { return this.userForm.get('email'); }
public get username() { return this.userForm.get('username'); }
public get password() { return this.userForm.get('password'); }
+ public get hasAdminRoleSelected() { return this.selectedRoles.includes('Admin'); };
constructor(public modal: NgbActiveModal, private accountService: AccountService) { }
@@ -38,6 +41,10 @@ export class EditUserComponent implements OnInit {
this.selectedRoles = roles;
}
+ updateRestrictionSelection(rating: AgeRating) {
+ this.selectedRating = rating;
+ }
+
updateLibrarySelection(libraries: Array<Library>) {
this.selectedLibraries = libraries.map(l => l.id);
}
@@ -51,6 +58,8 @@ export class EditUserComponent implements OnInit {
model.userId = this.member.id;
model.roles = this.selectedRoles;
model.libraries = this.selectedLibraries;
+ model.ageRestriction = this.selectedRating || AgeRating.NotApplicable;
+ console.log('rating: ', this.selectedRating);
this.accountService.update(model).subscribe(() => {
this.modal.close(true);
});
diff --git a/UI/Web/src/app/admin/invite-user/invite-user.component.html b/UI/Web/src/app/admin/invite-user/invite-user.component.html
index a4042ff89..541d32f11 100644
--- a/UI/Web/src/app/admin/invite-user/invite-user.component.html
+++ b/UI/Web/src/app/admin/invite-user/invite-user.component.html
@@ -1,55 +1,61 @@
-<div class="modal-header">
- <h4 class="modal-title" id="modal-basic-title">Invite User</h4>
- <button type="button" class="btn-close" aria-label="Close" (click)="close()">
+<div class="modal-container">
+ <div class="modal-header">
+ <h4 class="modal-title" id="modal-basic-title">Invite User</h4>
+ <button type="button" class="btn-close" aria-label="Close" (click)="close()"></button>
+ </div>
+ <div class="modal-body scrollable-modal">
+ <p>
+ Invite a user to your server. Enter their email in and we will send them an email to create an account. If you do not want to use our email service, you can <a href="https://wiki.kavitareader.com/en/guides/misc/email" rel="noopener noreferrer" target="_blank" rel="noopener noreferrer">host your own</a>
+ email service or use a fake email (Forgot User will not work). A link will be presented regardless and can be used to setup the email account manually.
+ </p>
- </button>
-</div>
-<div class="modal-body">
- <p>
- Invite a user to your server. Enter their email in and we will send them an email to create an account. If you do not want to use our email service, you can <a href="https://wiki.kavitareader.com/en/guides/misc/email" rel="noopener noreferrer" target="_blank" rel="noopener noreferrer">host your own</a>
- email service or use a fake email (Forgot User will not work). A link will be presented regardless and can be used to setup the email account manually.
- </p>
-
- <form [formGroup]="inviteForm" *ngIf="emailLink === ''">
- <div class="row g-0">
- <div class="mb-3" style="width:100%">
- <label for="email" class="form-label">Email</label>
- <input class="form-control" type="email" id="email" formControlName="email" required [class.is-invalid]="inviteForm.get('email')?.invalid && inviteForm.get('email')?.touched">
- <div id="inviteForm-validations" class="invalid-feedback" *ngIf="inviteForm.dirty || inviteForm.touched">
- <div *ngIf="email?.errors?.required">
- This field is required
+ <form [formGroup]="inviteForm" *ngIf="emailLink === ''">
+ <div class="row g-0">
+ <div class="mb-3" style="width:100%">
+ <label for="email" class="form-label">Email</label>
+ <input class="form-control" type="email" id="email" formControlName="email" required [class.is-invalid]="inviteForm.get('email')?.invalid && inviteForm.get('email')?.touched">
+ <div id="inviteForm-validations" class="invalid-feedback" *ngIf="inviteForm.dirty || inviteForm.touched">
+ <div *ngIf="email?.errors?.required">
+ This field is required
+ </div>
</div>
</div>
</div>
- </div>
-
- <div class="row g-0">
- <div class="col-md-6">
- <app-role-selector (selected)="updateRoleSelection($event)" [allowAdmin]="true"></app-role-selector>
+
+ <div class="row g-0">
+ <div class="col-md-6">
+ <app-role-selector (selected)="updateRoleSelection($event)" [allowAdmin]="true"></app-role-selector>
+ </div>
+
+ <div class="col-md-6">
+ <app-library-selector (selected)="updateLibrarySelection($event)"></app-library-selector>
+ </div>
</div>
-
- <div class="col-md-6">
- <app-library-selector (selected)="updateLibrarySelection($event)"></app-library-selector>
+
+ <div class="row g-0">
+ <div class="col-md-12">
+ <app-restriction-selector (selected)="updateRestrictionSelection($event)" [isAdmin]="hasAdminRoleSelected"></app-restriction-selector>
+ </div>
</div>
- </div>
- </form>
-
- <ng-container *ngIf="emailLink !== ''">
- <h4>User invited</h4>
- <p>You can use the following link below to setup the account for your user or use the copy button. You may need to log out before using the link to register a new user.
- If your server is externally accessible, an email will have been sent to the user and the links can be used by them to finish setting up their account.
- </p>
- <a class="email-link" href="{{emailLink}}" target="_blank" rel="noopener noreferrer">Setup user's account</a>
- <app-api-key title="Invite Url" tooltipText="Copy this and paste in a new tab. You may need to log out." [showRefresh]="false" [transform]="makeLink"></app-api-key>
- </ng-container>
-
-</div>
-<div class="modal-footer">
- <button type="button" class="btn btn-secondary" (click)="close()">
- Cancel
- </button>
- <button type="button" class="btn btn-primary" (click)="invite()" [disabled]="isSending || !inviteForm.valid || emailLink !== ''">
- <span *ngIf="isSending" class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
- <span>{{isSending ? 'Inviting...' : 'Invite'}}</span>
- </button>
-</div>
+ </form>
+
+ <ng-container *ngIf="emailLink !== ''">
+ <h4>User invited</h4>
+ <p>You can use the following link below to setup the account for your user or use the copy button. You may need to log out before using the link to register a new user.
+ If your server is externally accessible, an email will have been sent to the user and the links can be used by them to finish setting up their account.
+ </p>
+ <a class="email-link" href="{{emailLink}}" target="_blank" rel="noopener noreferrer">Setup user's account</a>
+ <app-api-key title="Invite Url" tooltipText="Copy this and paste in a new tab. You may need to log out." [showRefresh]="false" [transform]="makeLink"></app-api-key>
+ </ng-container>
+
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-secondary" (click)="close()">
+ Cancel
+ </button>
+ <button type="button" class="btn btn-primary" (click)="invite()" [disabled]="isSending || !inviteForm.valid || emailLink !== ''">
+ <span *ngIf="isSending" class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
+ <span>{{isSending ? 'Inviting...' : 'Invite'}}</span>
+ </button>
+ </div>
+</div>
\ No newline at end of file
diff --git a/UI/Web/src/app/admin/invite-user/invite-user.component.ts b/UI/Web/src/app/admin/invite-user/invite-user.component.ts
index 13f18b7eb..f031b3b8c 100644
--- a/UI/Web/src/app/admin/invite-user/invite-user.component.ts
+++ b/UI/Web/src/app/admin/invite-user/invite-user.component.ts
@@ -2,11 +2,10 @@ import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { ToastrService } from 'ngx-toastr';
-import { ConfirmService } from 'src/app/shared/confirm.service';
import { InviteUserResponse } from 'src/app/_models/invite-user-response';
import { Library } from 'src/app/_models/library';
+import { AgeRating } from 'src/app/_models/metadata/age-rating';
import { AccountService } from 'src/app/_services/account.service';
-import { ServerService } from 'src/app/_services/server.service';
@Component({
selector: 'app-invite-user',
@@ -22,14 +21,16 @@ export class InviteUserComponent implements OnInit {
inviteForm: FormGroup = new FormGroup({});
selectedRoles: Array<string> = [];
selectedLibraries: Array<number> = [];
+ selectedRating: AgeRating = AgeRating.NotApplicable;
emailLink: string = '';
makeLink: (val: string) => string = (val: string) => {return this.emailLink};
+ public get hasAdminRoleSelected() { return this.selectedRoles.includes('Admin'); };
+
public get email() { return this.inviteForm.get('email'); }
- constructor(public modal: NgbActiveModal, private accountService: AccountService, private serverService: ServerService,
- private confirmService: ConfirmService, private toastr: ToastrService) { }
+ constructor(public modal: NgbActiveModal, private accountService: AccountService, private toastr: ToastrService) { }
ngOnInit(): void {
this.inviteForm.addControl('email', new FormControl('', [Validators.required]));
@@ -47,6 +48,7 @@ export class InviteUserComponent implements OnInit {
email,
libraries: this.selectedLibraries,
roles: this.selectedRoles,
+ ageRestriction: this.selectedRating
}).subscribe((data: InviteUserResponse) => {
this.emailLink = data.emailLink;
this.isSending = false;
@@ -67,4 +69,8 @@ export class InviteUserComponent implements OnInit {
this.selectedLibraries = libraries.map(l => l.id);
}
+ updateRestrictionSelection(rating: AgeRating) {
+ this.selectedRating = rating;
+ }
+
}
diff --git a/UI/Web/src/app/admin/role-selector/role-selector.component.ts b/UI/Web/src/app/admin/role-selector/role-selector.component.ts
index ed00eaecd..e21c2d67c 100644
--- a/UI/Web/src/app/admin/role-selector/role-selector.component.ts
+++ b/UI/Web/src/app/admin/role-selector/role-selector.component.ts
@@ -1,6 +1,7 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Member } from 'src/app/_models/member';
+import { User } from 'src/app/_models/user';
import { AccountService } from 'src/app/_services/account.service';
import { MemberService } from 'src/app/_services/member.service';
@@ -11,7 +12,10 @@ import { MemberService } from 'src/app/_services/member.service';
})
export class RoleSelectorComponent implements OnInit {
- @Input() member: Member | undefined;
+ /**
+ * This must have roles
+ */
+ @Input() member: Member | undefined | User;
/**
* Allows the selection of Admin role
*/
@@ -25,7 +29,7 @@ export class RoleSelectorComponent implements OnInit {
ngOnInit(): void {
this.accountService.getRoles().subscribe(roles => {
- let bannedRoles = ['Pleb'];
+ const bannedRoles = ['Pleb'];
if (!this.allowAdmin) {
bannedRoles.push('Admin');
}
diff --git a/UI/Web/src/app/cards/_modals/edit-series-modal/edit-series-modal.component.scss b/UI/Web/src/app/cards/_modals/edit-series-modal/edit-series-modal.component.scss
index 6ed54f212..508a294da 100644
--- a/UI/Web/src/app/cards/_modals/edit-series-modal/edit-series-modal.component.scss
+++ b/UI/Web/src/app/cards/_modals/edit-series-modal/edit-series-modal.component.scss
@@ -1,8 +1,3 @@
-.scrollable-modal {
- max-height: calc(var(--vh) * 100 - 198px);
- overflow: auto;
-}
-
.lock-active {
> .input-group-text {
background-color: var(--primary-color);
diff --git a/UI/Web/src/app/cards/edit-series-relation/edit-series-relation.component.ts b/UI/Web/src/app/cards/edit-series-relation/edit-series-relation.component.ts
index 763976b8c..31e89c5d5 100644
--- a/UI/Web/src/app/cards/edit-series-relation/edit-series-relation.component.ts
+++ b/UI/Web/src/app/cards/edit-series-relation/edit-series-relation.component.ts
@@ -8,6 +8,7 @@ import { Series } from 'src/app/_models/series';
import { RelationKind, RelationKinds } from 'src/app/_models/series-detail/relation-kind';
import { ImageService } from 'src/app/_services/image.service';
import { LibraryService } from 'src/app/_services/library.service';
+import { SearchService } from 'src/app/_services/search.service';
import { SeriesService } from 'src/app/_services/series.service';
interface RelationControl {
@@ -47,7 +48,7 @@ export class EditSeriesRelationComponent implements OnInit, OnDestroy {
private onDestroy: Subject<void> = new Subject<void>();
constructor(private seriesService: SeriesService, private utilityService: UtilityService,
- public imageService: ImageService, private libraryService: LibraryService,
+ public imageService: ImageService, private libraryService: LibraryService, private searchService: SearchService,
private readonly cdRef: ChangeDetectorRef) {}
ngOnInit(): void {
@@ -127,7 +128,7 @@ export class EditSeriesRelationComponent implements OnInit, OnDestroy {
seriesSettings.id = 'relation--' + index;
seriesSettings.unique = true;
seriesSettings.addIfNonExisting = false;
- seriesSettings.fetchFn = (searchFilter: string) => this.libraryService.search(searchFilter).pipe(
+ seriesSettings.fetchFn = (searchFilter: string) => this.searchService.search(searchFilter).pipe(
map(group => group.series),
map(items => seriesSettings.compareFn(items, searchFilter)),
map(series => series.filter(s => s.seriesId !== this.series.id)),
@@ -142,7 +143,7 @@ export class EditSeriesRelationComponent implements OnInit, OnDestroy {
}
if (series !== undefined) {
- return this.libraryService.search(series.name).pipe(
+ return this.searchService.search(series.name).pipe(
map(group => group.series), map(results => {
seriesSettings.savedData = results.filter(s => s.seriesId === series.id);
return seriesSettings;
diff --git a/UI/Web/src/app/nav/nav-header/nav-header.component.ts b/UI/Web/src/app/nav/nav-header/nav-header.component.ts
index aeb8e9466..fd25b7887 100644
--- a/UI/Web/src/app/nav/nav-header/nav-header.component.ts
+++ b/UI/Web/src/app/nav/nav-header/nav-header.component.ts
@@ -6,7 +6,7 @@ import { debounceTime, distinctUntilChanged, filter, takeUntil, tap } from 'rxjs
import { Chapter } from 'src/app/_models/chapter';
import { MangaFile } from 'src/app/_models/manga-file';
import { ScrollService } from 'src/app/_services/scroll.service';
-import { SeriesService } from 'src/app/_services/series.service';
+import { SearchService } from 'src/app/_services/search.service';
import { FilterQueryParam } from '../../shared/_services/filter-utilities.service';
import { CollectionTag } from '../../_models/collection-tag';
import { Library } from '../../_models/library';
@@ -52,8 +52,8 @@ export class NavHeaderComponent implements OnInit, OnDestroy {
private readonly onDestroy = new Subject<void>();
constructor(public accountService: AccountService, private router: Router, public navService: NavService,
- private libraryService: LibraryService, public imageService: ImageService, @Inject(DOCUMENT) private document: Document,
- private scrollService: ScrollService, private seriesService: SeriesService, private readonly cdRef: ChangeDetectorRef) {
+ public imageService: ImageService, @Inject(DOCUMENT) private document: Document,
+ private scrollService: ScrollService, private searchService: SearchService, private readonly cdRef: ChangeDetectorRef) {
this.scrollElem = this.document.body;
}
@@ -110,7 +110,7 @@ export class NavHeaderComponent implements OnInit, OnDestroy {
this.searchTerm = val.trim();
this.cdRef.markForCheck();
- this.libraryService.search(val.trim()).pipe(takeUntil(this.onDestroy)).subscribe(results => {
+ this.searchService.search(val.trim()).pipe(takeUntil(this.onDestroy)).subscribe(results => {
this.searchResults = results;
this.isLoading = false;
this.cdRef.markForCheck();
@@ -185,7 +185,7 @@ export class NavHeaderComponent implements OnInit, OnDestroy {
clickFileSearchResult(item: MangaFile) {
this.clearSearch();
- this.seriesService.getSeriesForMangaFile(item.id).subscribe(series => {
+ this.searchService.getSeriesForMangaFile(item.id).subscribe(series => {
if (series !== undefined && series !== null) {
this.router.navigate(['library', series.libraryId, 'series', series.id]);
}
@@ -194,7 +194,7 @@ export class NavHeaderComponent implements OnInit, OnDestroy {
clickChapterSearchResult(item: Chapter) {
this.clearSearch();
- this.seriesService.getSeriesForChapter(item.id).subscribe(series => {
+ this.searchService.getSeriesForChapter(item.id).subscribe(series => {
if (series !== undefined && series !== null) {
this.router.navigate(['library', series.libraryId, 'series', series.id]);
}
diff --git a/UI/Web/src/app/pipe/age-rating.pipe.ts b/UI/Web/src/app/pipe/age-rating.pipe.ts
index 44cdb9056..f810692d9 100644
--- a/UI/Web/src/app/pipe/age-rating.pipe.ts
+++ b/UI/Web/src/app/pipe/age-rating.pipe.ts
@@ -11,7 +11,9 @@ export class AgeRatingPipe implements PipeTransform {
constructor(private metadataService: MetadataService) {}
- transform(value: AgeRating | AgeRatingDto): Observable<string> {
+ transform(value: AgeRating | AgeRatingDto | undefined): Observable<string> {
+ if (value === undefined || value === null) return of('undefined');
+
if (value.hasOwnProperty('title')) {
return of((value as AgeRatingDto).title);
}
diff --git a/UI/Web/src/app/pipe/default-value.pipe.ts b/UI/Web/src/app/pipe/default-value.pipe.ts
index 57acf9d2e..3e980f29d 100644
--- a/UI/Web/src/app/pipe/default-value.pipe.ts
+++ b/UI/Web/src/app/pipe/default-value.pipe.ts
@@ -6,7 +6,7 @@ import { Pipe, PipeTransform } from '@angular/core';
export class DefaultValuePipe implements PipeTransform {
transform(value: any, replacementString = '—'): string {
- if (value === null || value === undefined || value === '' || value === Infinity || value === NaN || value === {}) return replacementString;
+ if (value === null || value === undefined || value === '' || value === Infinity || value === NaN) return replacementString;
return value;
}
diff --git a/UI/Web/src/app/user-settings/change-age-restriction/change-age-restriction.component.html b/UI/Web/src/app/user-settings/change-age-restriction/change-age-restriction.component.html
new file mode 100644
index 000000000..b5475df75
--- /dev/null
+++ b/UI/Web/src/app/user-settings/change-age-restriction/change-age-restriction.component.html
@@ -0,0 +1,32 @@
+<div class="card mt-2">
+ <div class="card-body">
+ <div class="card-title">
+ <div class="row mb-2">
+ <div class="col-11"><h4 id="age-restriction">Age Restriction</h4></div>
+ <div class="col-1">
+ <button class="btn btn-primary btn-sm" (click)="toggleViewMode()" *ngIf="(hasChangeAgeRestrictionAbility | async)">{{isViewMode ? 'Edit' : 'Cancel'}}</button>
+ </div>
+ </div>
+ </div>
+
+ <ng-container *ngIf="isViewMode">
+ <span >{{user?.ageRestriction | ageRating | async}}</span>
+ </ng-container>
+
+ <div #collapse="ngbCollapse" [(ngbCollapse)]="isViewMode">
+ <ng-container *ngIf="user">
+ <app-restriction-selector (selected)="updateRestrictionSelection($event)" [showContext]="false" [member]="user" [reset]="reset"></app-restriction-selector>
+
+ <div class="col-auto d-flex d-md-block justify-content-sm-center text-md-end mb-3">
+ <button type="button" class="flex-fill btn btn-secondary me-2" aria-describedby="age-restriction" (click)="resetForm()">Reset</button>
+ <button type="submit" class="flex-fill btn btn-primary" aria-describedby="age-restriction" (click)="saveForm()">Save</button>
+ </div>
+ </ng-container>
+ </div>
+
+
+ </div>
+
+
+</div>
+
diff --git a/UI/Web/src/app/user-settings/change-age-restriction/change-age-restriction.component.scss b/UI/Web/src/app/user-settings/change-age-restriction/change-age-restriction.component.scss
new file mode 100644
index 000000000..e69de29bb
diff --git a/UI/Web/src/app/user-settings/change-age-restriction/change-age-restriction.component.ts b/UI/Web/src/app/user-settings/change-age-restriction/change-age-restriction.component.ts
new file mode 100644
index 000000000..d6e075391
--- /dev/null
+++ b/UI/Web/src/app/user-settings/change-age-restriction/change-age-restriction.component.ts
@@ -0,0 +1,79 @@
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, OnInit } from '@angular/core';
+import { ToastrService } from 'ngx-toastr';
+import { Observable, of, Subject, takeUntil, shareReplay, map, take } from 'rxjs';
+import { AgeRating } from 'src/app/_models/metadata/age-rating';
+import { User } from 'src/app/_models/user';
+import { AccountService } from 'src/app/_services/account.service';
+
+@Component({
+ selector: 'app-change-age-restriction',
+ templateUrl: './change-age-restriction.component.html',
+ styleUrls: ['./change-age-restriction.component.scss'],
+ changeDetection: ChangeDetectionStrategy.OnPush
+})
+export class ChangeAgeRestrictionComponent implements OnInit {
+
+ user: User | undefined = undefined;
+ hasChangeAgeRestrictionAbility: Observable<boolean> = of(false);
+ isViewMode: boolean = true;
+ selectedRating: AgeRating = AgeRating.NotApplicable;
+ originalRating!: AgeRating;
+ reset: EventEmitter<AgeRating> = new EventEmitter();
+
+ get AgeRating() { return AgeRating; }
+
+ private onDestroy = new Subject<void>();
+
+ constructor(private accountService: AccountService, private toastr: ToastrService, private readonly cdRef: ChangeDetectorRef) { }
+
+ ngOnInit(): void {
+ this.accountService.currentUser$.pipe(takeUntil(this.onDestroy), shareReplay(), take(1)).subscribe(user => {
+ this.user = user;
+ this.originalRating = this.user?.ageRestriction || AgeRating.NotApplicable;
+ this.cdRef.markForCheck();
+ });
+
+ this.hasChangeAgeRestrictionAbility = this.accountService.currentUser$.pipe(takeUntil(this.onDestroy), shareReplay(), map(user => {
+ return user !== undefined && (!this.accountService.hasAdminRole(user) && this.accountService.hasChangeAgeRestrictionRole(user));
+ }));
+ this.cdRef.markForCheck();
+ }
+
+ updateRestrictionSelection(rating: AgeRating) {
+ this.selectedRating = rating;
+ }
+
+ ngOnDestroy() {
+ this.onDestroy.next();
+ this.onDestroy.complete();
+ }
+
+ resetForm() {
+ if (!this.user) return;
+ console.log('resetting to ', this.originalRating)
+ this.reset.emit(this.originalRating);
+ this.cdRef.markForCheck();
+ }
+
+ saveForm() {
+ if (this.user === undefined) { return; }
+
+ this.accountService.updateAgeRestriction(this.selectedRating).subscribe(() => {
+ this.toastr.success('Age Restriction has been updated');
+ this.originalRating = this.selectedRating;
+ if (this.user) {
+ this.user.ageRestriction = this.selectedRating;
+ }
+ this.resetForm();
+ this.isViewMode = true;
+ }, err => {
+
+ });
+ }
+
+ toggleViewMode() {
+ this.isViewMode = !this.isViewMode;
+ this.resetForm();
+ }
+
+}
diff --git a/UI/Web/src/app/user-settings/change-password/change-password.component.ts b/UI/Web/src/app/user-settings/change-password/change-password.component.ts
index 91eb78123..fa01ee114 100644
--- a/UI/Web/src/app/user-settings/change-password/change-password.component.ts
+++ b/UI/Web/src/app/user-settings/change-password/change-password.component.ts
@@ -1,7 +1,7 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { ToastrService } from 'ngx-toastr';
-import { map, Observable, of, shareReplay, Subject, takeUntil } from 'rxjs';
+import { map, Observable, of, shareReplay, Subject, take, takeUntil } from 'rxjs';
import { User } from 'src/app/_models/user';
import { AccountService } from 'src/app/_services/account.service';
@@ -29,6 +29,12 @@ export class ChangePasswordComponent implements OnInit, OnDestroy {
constructor(private accountService: AccountService, private toastr: ToastrService, private readonly cdRef: ChangeDetectorRef) { }
ngOnInit(): void {
+
+ this.accountService.currentUser$.pipe(takeUntil(this.onDestroy), shareReplay(), take(1)).subscribe(user => {
+ this.user = user;
+ this.cdRef.markForCheck();
+ });
+
this.hasChangePasswordAbility = this.accountService.currentUser$.pipe(takeUntil(this.onDestroy), shareReplay(), map(user => {
return user !== undefined && (this.accountService.hasAdminRole(user) || this.accountService.hasChangePasswordRole(user));
}));
@@ -38,8 +44,6 @@ export class ChangePasswordComponent implements OnInit, OnDestroy {
this.passwordChangeForm.addControl('confirmPassword', new FormControl('', [Validators.required]));
this.passwordChangeForm.addControl('oldPassword', new FormControl('', [Validators.required]));
-
-
this.observableHandles.push(this.passwordChangeForm.valueChanges.subscribe(() => {
const values = this.passwordChangeForm.value;
this.passwordsMatch = values.password === values.confirmPassword;
diff --git a/UI/Web/src/app/user-settings/restriction-selector/restriction-selector.component.html b/UI/Web/src/app/user-settings/restriction-selector/restriction-selector.component.html
new file mode 100644
index 000000000..757504e8a
--- /dev/null
+++ b/UI/Web/src/app/user-settings/restriction-selector/restriction-selector.component.html
@@ -0,0 +1,19 @@
+<ng-container *ngIf="restrictionForm">
+ <ng-container *ngIf="showContext">
+ <h4>Age Rating Restriction</h4>
+ <p>When selected, all series and reading lists that have at least one item that is greater than the selected restriction will be pruned from results.
+ <ng-container *ngIf="isAdmin">This is not applicable for admins.</ng-container>
+ </p>
+ </ng-container>
+ <form [formGroup]="restrictionForm">
+ <div class="mb-3">
+ <label for="age-rating" class="form-label visually-hidden">Age Rating</label>
+ <div class="input-group">
+ <select class="form-select"id="age-rating" formControlName="ageRating">
+ <option value="-1">No Restriction</option>
+ <option *ngFor="let opt of ageRatings" [value]="opt.value">{{opt.title | titlecase}}</option>
+ </select>
+ </div>
+ </div>
+ </form>
+</ng-container>
\ No newline at end of file
diff --git a/UI/Web/src/app/user-settings/restriction-selector/restriction-selector.component.scss b/UI/Web/src/app/user-settings/restriction-selector/restriction-selector.component.scss
new file mode 100644
index 000000000..e69de29bb
diff --git a/UI/Web/src/app/user-settings/restriction-selector/restriction-selector.component.ts b/UI/Web/src/app/user-settings/restriction-selector/restriction-selector.component.ts
new file mode 100644
index 000000000..f141721e2
--- /dev/null
+++ b/UI/Web/src/app/user-settings/restriction-selector/restriction-selector.component.ts
@@ -0,0 +1,68 @@
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core';
+import { FormControl, FormGroup } from '@angular/forms';
+import { Member } from 'src/app/_models/member';
+import { AgeRating } from 'src/app/_models/metadata/age-rating';
+import { AgeRatingDto } from 'src/app/_models/metadata/age-rating-dto';
+import { User } from 'src/app/_models/user';
+import { MetadataService } from 'src/app/_services/metadata.service';
+
+@Component({
+ selector: 'app-restriction-selector',
+ templateUrl: './restriction-selector.component.html',
+ styleUrls: ['./restriction-selector.component.scss'],
+ changeDetection: ChangeDetectionStrategy.OnPush
+})
+export class RestrictionSelectorComponent implements OnInit, OnChanges {
+
+ @Input() member: Member | undefined | User;
+ @Input() isAdmin: boolean = false;
+ /**
+ * Show labels and description around the form
+ */
+ @Input() showContext: boolean = true;
+ @Input() reset: EventEmitter<AgeRating> | undefined;
+ @Output() selected: EventEmitter<AgeRating> = new EventEmitter<AgeRating>();
+
+
+ ageRatings: Array<AgeRatingDto> = [];
+ restrictionForm: FormGroup | undefined;
+
+ constructor(private metadataService: MetadataService, private readonly cdRef: ChangeDetectorRef) { }
+
+ ngOnInit(): void {
+
+ this.restrictionForm = new FormGroup({
+ 'ageRating': new FormControl(this.member?.ageRestriction || AgeRating.NotApplicable, [])
+ });
+
+ if (this.isAdmin) {
+ this.restrictionForm.get('ageRating')?.disable();
+ }
+
+ if (this.reset) {
+ this.reset.subscribe(e => {
+ this.restrictionForm?.get('ageRating')?.setValue(e);
+ this.cdRef.markForCheck();
+ });
+ }
+
+ this.restrictionForm.get('ageRating')?.valueChanges.subscribe(e => {
+ this.selected.emit(parseInt(e, 10));
+ });
+
+ this.metadataService.getAllAgeRatings().subscribe(ratings => {
+ this.ageRatings = ratings;
+ this.cdRef.markForCheck();
+ });
+
+
+ }
+
+ ngOnChanges() {
+ if (!this.member) return;
+ console.log('changes: ');
+ this.restrictionForm?.get('ageRating')?.setValue(this.member?.ageRestriction || AgeRating.NotApplicable);
+ this.cdRef.markForCheck();
+ }
+
+}
diff --git a/UI/Web/src/app/user-settings/user-preferences/user-preferences.component.html b/UI/Web/src/app/user-settings/user-preferences/user-preferences.component.html
index 6600acb09..7b1be904d 100644
--- a/UI/Web/src/app/user-settings/user-preferences/user-preferences.component.html
+++ b/UI/Web/src/app/user-settings/user-preferences/user-preferences.component.html
@@ -11,6 +11,7 @@
<ng-container *ngIf="tab.fragment === FragmentID.Account">
<app-change-email></app-change-email>
<app-change-password></app-change-password>
+ <app-change-age-restriction></app-change-age-restriction>
</ng-container>
<ng-container *ngIf="tab.fragment === FragmentID.Prefernces">
<p>
diff --git a/UI/Web/src/app/user-settings/user-settings.module.ts b/UI/Web/src/app/user-settings/user-settings.module.ts
index 8563f06ac..d338683d3 100644
--- a/UI/Web/src/app/user-settings/user-settings.module.ts
+++ b/UI/Web/src/app/user-settings/user-settings.module.ts
@@ -15,6 +15,8 @@ import { DevicePlatformPipe } from './_pipes/device-platform.pipe';
import { EditDeviceComponent } from './edit-device/edit-device.component';
import { ChangePasswordComponent } from './change-password/change-password.component';
import { ChangeEmailComponent } from './change-email/change-email.component';
+import { ChangeAgeRestrictionComponent } from './change-age-restriction/change-age-restriction.component';
+import { RestrictionSelectorComponent } from './restriction-selector/restriction-selector.component';
@NgModule({
@@ -28,6 +30,8 @@ import { ChangeEmailComponent } from './change-email/change-email.component';
EditDeviceComponent,
ChangePasswordComponent,
ChangeEmailComponent,
+ RestrictionSelectorComponent,
+ ChangeAgeRestrictionComponent,
],
imports: [
CommonModule,
@@ -47,7 +51,8 @@ import { ChangeEmailComponent } from './change-email/change-email.component';
],
exports: [
SiteThemeProviderPipe,
- ApiKeyComponent
+ ApiKeyComponent,
+ RestrictionSelectorComponent
]
})
export class UserSettingsModule { }
diff --git a/UI/Web/src/theme/components/_modal.scss b/UI/Web/src/theme/components/_modal.scss
index 6adf93ca0..cd6bd1f8e 100644
--- a/UI/Web/src/theme/components/_modal.scss
+++ b/UI/Web/src/theme/components/_modal.scss
@@ -6,3 +6,8 @@
.modal-title {
word-break: break-all;
}
+
+.scrollable-modal {
+ max-height: calc(var(--vh) * 100 - 198px);
+ overflow: auto;
+}