diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index cdd72de1c..805c3b61d 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -28,7 +28,7 @@ body:
label: Kavita Version Number - If you don't see your version number listed, please update Kavita and see if your issue still persists.
multiple: false
options:
- - 0.8.6.2 - Stable
+ - 0.8.7 - Stable
- Nightly Testing Branch
validations:
required: true
diff --git a/API.Benchmark/API.Benchmark.csproj b/API.Benchmark/API.Benchmark.csproj
index 38ec425fe..ec9c1884f 100644
--- a/API.Benchmark/API.Benchmark.csproj
+++ b/API.Benchmark/API.Benchmark.csproj
@@ -10,8 +10,8 @@
-
-
+
+
@@ -26,5 +26,10 @@
Always
+
+
+ PreserveNewest
+
+
diff --git a/API.Benchmark/Data/AesopsFables.epub b/API.Benchmark/Data/AesopsFables.epub
new file mode 100644
index 000000000..d2ab9a8b2
Binary files /dev/null and b/API.Benchmark/Data/AesopsFables.epub differ
diff --git a/API.Benchmark/KoreaderHashBenchmark.cs b/API.Benchmark/KoreaderHashBenchmark.cs
new file mode 100644
index 000000000..c0abfd2ad
--- /dev/null
+++ b/API.Benchmark/KoreaderHashBenchmark.cs
@@ -0,0 +1,41 @@
+using API.Helpers.Builders;
+using BenchmarkDotNet.Attributes;
+using BenchmarkDotNet.Order;
+using System;
+using API.Entities.Enums;
+
+namespace API.Benchmark
+{
+ [StopOnFirstError]
+ [MemoryDiagnoser]
+ [RankColumn]
+ [Orderer(SummaryOrderPolicy.FastestToSlowest)]
+ [SimpleJob(launchCount: 1, warmupCount: 5, invocationCount: 20)]
+ public class KoreaderHashBenchmark
+ {
+ private const string sourceEpub = "./Data/AesopsFables.epub";
+
+ [Benchmark(Baseline = true)]
+ public void TestBuildManga_baseline()
+ {
+ var file = new MangaFileBuilder(sourceEpub, MangaFormat.Epub)
+ .Build();
+ if (file == null)
+ {
+ throw new Exception("Failed to build manga file");
+ }
+ }
+
+ [Benchmark]
+ public void TestBuildManga_withHash()
+ {
+ var file = new MangaFileBuilder(sourceEpub, MangaFormat.Epub)
+ .WithHash()
+ .Build();
+ if (file == null)
+ {
+ throw new Exception("Failed to build manga file");
+ }
+ }
+ }
+}
diff --git a/API.Tests/API.Tests.csproj b/API.Tests/API.Tests.csproj
index 20e10e548..a571a6e72 100644
--- a/API.Tests/API.Tests.csproj
+++ b/API.Tests/API.Tests.csproj
@@ -6,13 +6,13 @@
-
-
+
+
-
-
+
+
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
@@ -36,4 +36,10 @@
+
+
+ PreserveNewest
+
+
+
diff --git a/API.Tests/Data/AesopsFables.epub b/API.Tests/Data/AesopsFables.epub
new file mode 100644
index 000000000..d2ab9a8b2
Binary files /dev/null and b/API.Tests/Data/AesopsFables.epub differ
diff --git a/API.Tests/Extensions/QueryableExtensionsTests.cs b/API.Tests/Extensions/QueryableExtensionsTests.cs
index 866e0202c..96d74b46d 100644
--- a/API.Tests/Extensions/QueryableExtensionsTests.cs
+++ b/API.Tests/Extensions/QueryableExtensionsTests.cs
@@ -67,7 +67,7 @@ public class QueryableExtensionsTests
[Theory]
[InlineData(true, 2)]
- [InlineData(false, 1)]
+ [InlineData(false, 2)]
public void RestrictAgainstAgeRestriction_Genre_ShouldRestrictEverythingAboveTeen(bool includeUnknowns, int expectedCount)
{
var items = new List()
@@ -94,7 +94,7 @@ public class QueryableExtensionsTests
[Theory]
[InlineData(true, 2)]
- [InlineData(false, 1)]
+ [InlineData(false, 2)]
public void RestrictAgainstAgeRestriction_Tag_ShouldRestrictEverythingAboveTeen(bool includeUnknowns, int expectedCount)
{
var items = new List()
diff --git a/API.Tests/Helpers/BookSortTitlePrefixHelperTests.cs b/API.Tests/Helpers/BookSortTitlePrefixHelperTests.cs
new file mode 100644
index 000000000..e1f585806
--- /dev/null
+++ b/API.Tests/Helpers/BookSortTitlePrefixHelperTests.cs
@@ -0,0 +1,178 @@
+using API.Helpers;
+using Xunit;
+
+namespace API.Tests.Helpers;
+
+public class BookSortTitlePrefixHelperTests
+{
+ [Theory]
+ [InlineData("The Avengers", "Avengers")]
+ [InlineData("A Game of Thrones", "Game of Thrones")]
+ [InlineData("An American Tragedy", "American Tragedy")]
+ public void TestEnglishPrefixes(string inputString, string expected)
+ {
+ Assert.Equal(expected, BookSortTitlePrefixHelper.GetSortTitle(inputString));
+ }
+
+ [Theory]
+ [InlineData("El Quijote", "Quijote")]
+ [InlineData("La Casa de Papel", "Casa de Papel")]
+ [InlineData("Los Miserables", "Miserables")]
+ [InlineData("Las Vegas", "Vegas")]
+ [InlineData("Un Mundo Feliz", "Mundo Feliz")]
+ [InlineData("Una Historia", "Historia")]
+ public void TestSpanishPrefixes(string inputString, string expected)
+ {
+ Assert.Equal(expected, BookSortTitlePrefixHelper.GetSortTitle(inputString));
+ }
+
+ [Theory]
+ [InlineData("Le Petit Prince", "Petit Prince")]
+ [InlineData("La Belle et la Bête", "Belle et la Bête")]
+ [InlineData("Les Misérables", "Misérables")]
+ [InlineData("Un Amour de Swann", "Amour de Swann")]
+ [InlineData("Une Vie", "Vie")]
+ [InlineData("Des Souris et des Hommes", "Souris et des Hommes")]
+ public void TestFrenchPrefixes(string inputString, string expected)
+ {
+ Assert.Equal(expected, BookSortTitlePrefixHelper.GetSortTitle(inputString));
+ }
+
+ [Theory]
+ [InlineData("Der Herr der Ringe", "Herr der Ringe")]
+ [InlineData("Die Verwandlung", "Verwandlung")]
+ [InlineData("Das Kapital", "Kapital")]
+ [InlineData("Ein Sommernachtstraum", "Sommernachtstraum")]
+ [InlineData("Eine Geschichte", "Geschichte")]
+ public void TestGermanPrefixes(string inputString, string expected)
+ {
+ Assert.Equal(expected, BookSortTitlePrefixHelper.GetSortTitle(inputString));
+ }
+
+ [Theory]
+ [InlineData("Il Nome della Rosa", "Nome della Rosa")]
+ [InlineData("La Divina Commedia", "Divina Commedia")]
+ [InlineData("Lo Hobbit", "Hobbit")]
+ [InlineData("Gli Ultimi", "Ultimi")]
+ [InlineData("Le Città Invisibili", "Città Invisibili")]
+ [InlineData("Un Giorno", "Giorno")]
+ [InlineData("Una Notte", "Notte")]
+ public void TestItalianPrefixes(string inputString, string expected)
+ {
+ Assert.Equal(expected, BookSortTitlePrefixHelper.GetSortTitle(inputString));
+ }
+
+ [Theory]
+ [InlineData("O Alquimista", "Alquimista")]
+ [InlineData("A Moreninha", "Moreninha")]
+ [InlineData("Os Lusíadas", "Lusíadas")]
+ [InlineData("As Meninas", "Meninas")]
+ [InlineData("Um Defeito de Cor", "Defeito de Cor")]
+ [InlineData("Uma História", "História")]
+ public void TestPortuguesePrefixes(string inputString, string expected)
+ {
+ Assert.Equal(expected, BookSortTitlePrefixHelper.GetSortTitle(inputString));
+ }
+
+ [Theory]
+ [InlineData("", "")] // Empty string returns empty
+ [InlineData("Book", "Book")] // Single word, no change
+ [InlineData("Avengers", "Avengers")] // No prefix, no change
+ public void TestNoPrefixCases(string inputString, string expected)
+ {
+ Assert.Equal(expected, BookSortTitlePrefixHelper.GetSortTitle(inputString));
+ }
+
+ [Theory]
+ [InlineData("The", "The")] // Just a prefix word alone
+ [InlineData("A", "A")] // Just single letter prefix alone
+ [InlineData("Le", "Le")] // French prefix alone
+ public void TestPrefixWordAlone(string inputString, string expected)
+ {
+ Assert.Equal(expected, BookSortTitlePrefixHelper.GetSortTitle(inputString));
+ }
+
+ [Theory]
+ [InlineData("THE AVENGERS", "AVENGERS")] // All caps
+ [InlineData("the avengers", "avengers")] // All lowercase
+ [InlineData("The AVENGERS", "AVENGERS")] // Mixed case
+ [InlineData("tHe AvEnGeRs", "AvEnGeRs")] // Random case
+ public void TestCaseInsensitivity(string inputString, string expected)
+ {
+ Assert.Equal(expected, BookSortTitlePrefixHelper.GetSortTitle(inputString));
+ }
+
+ [Theory]
+ [InlineData("Then Came You", "Then Came You")] // "The" + "n" = not a prefix
+ [InlineData("And Then There Were None", "And Then There Were None")] // "An" + "d" = not a prefix
+ [InlineData("Elsewhere", "Elsewhere")] // "El" + "sewhere" = not a prefix (no space)
+ [InlineData("Lesson Plans", "Lesson Plans")] // "Les" + "son" = not a prefix (no space)
+ [InlineData("Theory of Everything", "Theory of Everything")] // "The" + "ory" = not a prefix
+ public void TestFalsePositivePrefixes(string inputString, string expected)
+ {
+ Assert.Equal(expected, BookSortTitlePrefixHelper.GetSortTitle(inputString));
+ }
+
+ [Theory]
+ [InlineData("The ", "The ")] // Prefix with only space after - returns original
+ [InlineData("La ", "La ")] // Same for other languages
+ [InlineData("El ", "El ")] // Same for Spanish
+ public void TestPrefixWithOnlySpaceAfter(string inputString, string expected)
+ {
+ Assert.Equal(expected, BookSortTitlePrefixHelper.GetSortTitle(inputString));
+ }
+
+ [Theory]
+ [InlineData("The Multiple Spaces", " Multiple Spaces")] // Doesn't trim extra spaces from remainder
+ [InlineData("Le Petit Prince", " Petit Prince")] // Leading space preserved in remainder
+ public void TestSpaceHandling(string inputString, string expected)
+ {
+ Assert.Equal(expected, BookSortTitlePrefixHelper.GetSortTitle(inputString));
+ }
+
+ [Theory]
+ [InlineData("The The Matrix", "The Matrix")] // Removes first "The", leaves second
+ [InlineData("A A Clockwork Orange", "A Clockwork Orange")] // Removes first "A", leaves second
+ [InlineData("El El Cid", "El Cid")] // Spanish version
+ public void TestRepeatedPrefixes(string inputString, string expected)
+ {
+ Assert.Equal(expected, BookSortTitlePrefixHelper.GetSortTitle(inputString));
+ }
+
+ [Theory]
+ [InlineData("L'Étranger", "L'Étranger")] // French contraction - no space, no change
+ [InlineData("D'Artagnan", "D'Artagnan")] // Contraction - no space, no change
+ [InlineData("The-Matrix", "The-Matrix")] // Hyphen instead of space - no change
+ [InlineData("The.Avengers", "The.Avengers")] // Period instead of space - no change
+ public void TestNonSpaceSeparators(string inputString, string expected)
+ {
+ Assert.Equal(expected, BookSortTitlePrefixHelper.GetSortTitle(inputString));
+ }
+
+ [Theory]
+ [InlineData("三国演义", "三国演义")] // Chinese - no processing due to CJK detection
+ [InlineData("한국어", "한국어")] // Korean - not in CJK range, would be processed normally
+ public void TestCjkLanguages(string inputString, string expected)
+ {
+ // NOTE: These don't do anything, I am waiting for user input on if these are needed
+ Assert.Equal(expected, BookSortTitlePrefixHelper.GetSortTitle(inputString));
+ }
+
+ [Theory]
+ [InlineData("नमस्ते दुनिया", "नमस्ते दुनिया")] // Hindi - not CJK, processed normally
+ [InlineData("مرحبا بالعالم", "مرحبا بالعالم")] // Arabic - not CJK, processed normally
+ [InlineData("שלום עולם", "שלום עולם")] // Hebrew - not CJK, processed normally
+ public void TestNonLatinNonCjkScripts(string inputString, string expected)
+ {
+ Assert.Equal(expected, BookSortTitlePrefixHelper.GetSortTitle(inputString));
+ }
+
+ [Theory]
+ [InlineData("в мире", "мире")] // Russian "в" (in) - should be removed
+ [InlineData("на столе", "столе")] // Russian "на" (on) - should be removed
+ [InlineData("с друзьями", "друзьями")] // Russian "с" (with) - should be removed
+ public void TestRussianPrefixes(string inputString, string expected)
+ {
+ Assert.Equal(expected, BookSortTitlePrefixHelper.GetSortTitle(inputString));
+ }
+}
diff --git a/API.Tests/Helpers/KoreaderHelperTests.cs b/API.Tests/Helpers/KoreaderHelperTests.cs
new file mode 100644
index 000000000..66d287a5d
--- /dev/null
+++ b/API.Tests/Helpers/KoreaderHelperTests.cs
@@ -0,0 +1,60 @@
+using API.DTOs.Koreader;
+using API.DTOs.Progress;
+using API.Helpers;
+using System.Runtime.CompilerServices;
+using Xunit;
+
+namespace API.Tests.Helpers;
+
+
+public class KoreaderHelperTests
+{
+
+ [Theory]
+ [InlineData("/body/DocFragment[11]/body/div/a", 10, null)]
+ [InlineData("/body/DocFragment[1]/body/div/p[40]", 0, 40)]
+ [InlineData("/body/DocFragment[8]/body/div/p[28]/text().264", 7, 28)]
+ public void GetEpubPositionDto(string koreaderPosition, int page, int? pNumber)
+ {
+ var expected = EmptyProgressDto();
+ expected.BookScrollId = pNumber.HasValue ? $"//html[1]/BODY/APP-ROOT[1]/DIV[1]/DIV[1]/DIV[1]/APP-BOOK-READER[1]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[1]/P[{pNumber}]" : null;
+ expected.PageNum = page;
+ var actual = EmptyProgressDto();
+
+ KoreaderHelper.UpdateProgressDto(actual, koreaderPosition);
+ Assert.Equal(expected.BookScrollId, actual.BookScrollId);
+ Assert.Equal(expected.PageNum, actual.PageNum);
+ }
+
+
+ [Theory]
+ [InlineData("//html[1]/BODY/APP-ROOT[1]/DIV[1]/DIV[1]/DIV[1]/APP-BOOK-READER[1]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/DIV[1]/P[20]", 5, "/body/DocFragment[6]/body/div/p[20]")]
+ [InlineData(null, 10, "/body/DocFragment[11]/body/div/a")]
+ public void GetKoreaderPosition(string scrollId, int page, string koreaderPosition)
+ {
+ var given = EmptyProgressDto();
+ given.BookScrollId = scrollId;
+ given.PageNum = page;
+
+ Assert.Equal(koreaderPosition, KoreaderHelper.GetKoreaderPosition(given));
+ }
+
+ [Theory]
+ [InlineData("./Data/AesopsFables.epub", "8795ACA4BF264B57C1EEDF06A0CEE688")]
+ public void GetKoreaderHash(string filePath, string hash)
+ {
+ Assert.Equal(KoreaderHelper.HashContents(filePath), hash);
+ }
+
+ private ProgressDto EmptyProgressDto()
+ {
+ return new ProgressDto
+ {
+ ChapterId = 0,
+ PageNum = 0,
+ VolumeId = 0,
+ SeriesId = 0,
+ LibraryId = 0
+ };
+ }
+}
diff --git a/API.Tests/Helpers/PersonHelperTests.cs b/API.Tests/Helpers/PersonHelperTests.cs
index 66713e17c..47dab48da 100644
--- a/API.Tests/Helpers/PersonHelperTests.cs
+++ b/API.Tests/Helpers/PersonHelperTests.cs
@@ -1,5 +1,10 @@
-using System.Linq;
+using System.Collections.Generic;
+using System.Linq;
using System.Threading.Tasks;
+using API.Entities.Enums;
+using API.Helpers;
+using API.Helpers.Builders;
+using Xunit;
namespace API.Tests.Helpers;
@@ -7,127 +12,215 @@ public class PersonHelperTests : AbstractDbTest
{
protected override async Task ResetDb()
{
+ Context.Series.RemoveRange(Context.Series.ToList());
+ Context.Person.RemoveRange(Context.Person.ToList());
+ Context.Library.RemoveRange(Context.Library.ToList());
Context.Series.RemoveRange(Context.Series.ToList());
await Context.SaveChangesAsync();
}
- //
- // // 1. Test adding new people and keeping existing ones
- // [Fact]
- // public async Task UpdateChapterPeopleAsync_AddNewPeople_ExistingPersonRetained()
- // {
- // var existingPerson = new PersonBuilder("Joe Shmo").Build();
- // var chapter = new ChapterBuilder("1").Build();
- //
- // // Create an existing person and assign them to the series with a role
- // var series = new SeriesBuilder("Test 1")
- // .WithFormat(MangaFormat.Archive)
- // .WithMetadata(new SeriesMetadataBuilder()
- // .WithPerson(existingPerson, PersonRole.Editor)
- // .Build())
- // .WithVolume(new VolumeBuilder("1").WithChapter(chapter).Build())
- // .Build();
- //
- // _unitOfWork.SeriesRepository.Add(series);
- // await _unitOfWork.CommitAsync();
- //
- // // Call UpdateChapterPeopleAsync with one existing and one new person
- // await PersonHelper.UpdateChapterPeopleAsync(chapter, new List { "Joe Shmo", "New Person" }, PersonRole.Editor, _unitOfWork);
- //
- // // Assert existing person retained and new person added
- // var people = await _unitOfWork.PersonRepository.GetAllPeople();
- // Assert.Contains(people, p => p.Name == "Joe Shmo");
- // Assert.Contains(people, p => p.Name == "New Person");
- //
- // var chapterPeople = chapter.People.Select(cp => cp.Person.Name).ToList();
- // Assert.Contains("Joe Shmo", chapterPeople);
- // Assert.Contains("New Person", chapterPeople);
- // }
- //
- // // 2. Test removing a person no longer in the list
- // [Fact]
- // public async Task UpdateChapterPeopleAsync_RemovePeople()
- // {
- // var existingPerson1 = new PersonBuilder("Joe Shmo").Build();
- // var existingPerson2 = new PersonBuilder("Jane Doe").Build();
- // var chapter = new ChapterBuilder("1").Build();
- //
- // var series = new SeriesBuilder("Test 1")
- // .WithVolume(new VolumeBuilder("1")
- // .WithChapter(new ChapterBuilder("1")
- // .WithPerson(existingPerson1, PersonRole.Editor)
- // .WithPerson(existingPerson2, PersonRole.Editor)
- // .Build())
- // .Build())
- // .Build();
- //
- // _unitOfWork.SeriesRepository.Add(series);
- // await _unitOfWork.CommitAsync();
- //
- // // Call UpdateChapterPeopleAsync with only one person
- // await PersonHelper.UpdateChapterPeopleAsync(chapter, new List { "Joe Shmo" }, PersonRole.Editor, _unitOfWork);
- //
- // var people = await _unitOfWork.PersonRepository.GetAllPeople();
- // Assert.DoesNotContain(people, p => p.Name == "Jane Doe");
- //
- // var chapterPeople = chapter.People.Select(cp => cp.Person.Name).ToList();
- // Assert.Contains("Joe Shmo", chapterPeople);
- // Assert.DoesNotContain("Jane Doe", chapterPeople);
- // }
- //
- // // 3. Test no changes when the list of people is the same
- // [Fact]
- // public async Task UpdateChapterPeopleAsync_NoChanges()
- // {
- // var existingPerson = new PersonBuilder("Joe Shmo").Build();
- // var chapter = new ChapterBuilder("1").Build();
- //
- // var series = new SeriesBuilder("Test 1")
- // .WithVolume(new VolumeBuilder("1")
- // .WithChapter(new ChapterBuilder("1")
- // .WithPerson(existingPerson, PersonRole.Editor)
- // .Build())
- // .Build())
- // .Build();
- //
- // _unitOfWork.SeriesRepository.Add(series);
- // await _unitOfWork.CommitAsync();
- //
- // // Call UpdateChapterPeopleAsync with the same list
- // await PersonHelper.UpdateChapterPeopleAsync(chapter, new List { "Joe Shmo" }, PersonRole.Editor, _unitOfWork);
- //
- // var people = await _unitOfWork.PersonRepository.GetAllPeople();
- // Assert.Contains(people, p => p.Name == "Joe Shmo");
- //
- // var chapterPeople = chapter.People.Select(cp => cp.Person.Name).ToList();
- // Assert.Contains("Joe Shmo", chapterPeople);
- // Assert.Single(chapter.People); // No duplicate entries
- // }
- //
- // // 4. Test multiple roles for a person
- // [Fact]
- // public async Task UpdateChapterPeopleAsync_MultipleRoles()
- // {
- // var person = new PersonBuilder("Joe Shmo").Build();
- // var chapter = new ChapterBuilder("1").Build();
- //
- // var series = new SeriesBuilder("Test 1")
- // .WithVolume(new VolumeBuilder("1")
- // .WithChapter(new ChapterBuilder("1")
- // .WithPerson(person, PersonRole.Writer) // Assign person as Writer
- // .Build())
- // .Build())
- // .Build();
- //
- // _unitOfWork.SeriesRepository.Add(series);
- // await _unitOfWork.CommitAsync();
- //
- // // Add same person as Editor
- // await PersonHelper.UpdateChapterPeopleAsync(chapter, new List { "Joe Shmo" }, PersonRole.Editor, _unitOfWork);
- //
- // // Ensure that the same person is assigned with two roles
- // var chapterPeople = chapter.People.Where(cp => cp.Person.Name == "Joe Shmo").ToList();
- // Assert.Equal(2, chapterPeople.Count); // One for each role
- // Assert.Contains(chapterPeople, cp => cp.Role == PersonRole.Writer);
- // Assert.Contains(chapterPeople, cp => cp.Role == PersonRole.Editor);
- // }
+
+ // 1. Test adding new people and keeping existing ones
+ [Fact]
+ public async Task UpdateChapterPeopleAsync_AddNewPeople_ExistingPersonRetained()
+ {
+ await ResetDb();
+
+ var library = new LibraryBuilder("My Library")
+ .Build();
+
+ UnitOfWork.LibraryRepository.Add(library);
+ await UnitOfWork.CommitAsync();
+
+ var existingPerson = new PersonBuilder("Joe Shmo").Build();
+ var chapter = new ChapterBuilder("1").Build();
+
+ // Create an existing person and assign them to the series with a role
+ var series = new SeriesBuilder("Test 1")
+ .WithLibraryId(library.Id)
+ .WithFormat(MangaFormat.Archive)
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithPerson(existingPerson, PersonRole.Editor)
+ .Build())
+ .WithVolume(new VolumeBuilder("1").WithChapter(chapter).Build())
+ .Build();
+
+ UnitOfWork.SeriesRepository.Add(series);
+ await UnitOfWork.CommitAsync();
+
+ // Call UpdateChapterPeopleAsync with one existing and one new person
+ await PersonHelper.UpdateChapterPeopleAsync(chapter, new List { "Joe Shmo", "New Person" }, PersonRole.Editor, UnitOfWork);
+
+ // Assert existing person retained and new person added
+ var people = await UnitOfWork.PersonRepository.GetAllPeople();
+ Assert.Contains(people, p => p.Name == "Joe Shmo");
+ Assert.Contains(people, p => p.Name == "New Person");
+
+ var chapterPeople = chapter.People.Select(cp => cp.Person.Name).ToList();
+ Assert.Contains("Joe Shmo", chapterPeople);
+ Assert.Contains("New Person", chapterPeople);
+ }
+
+ // 2. Test removing a person no longer in the list
+ [Fact]
+ public async Task UpdateChapterPeopleAsync_RemovePeople()
+ {
+ await ResetDb();
+
+ var library = new LibraryBuilder("My Library")
+ .Build();
+
+ UnitOfWork.LibraryRepository.Add(library);
+ await UnitOfWork.CommitAsync();
+
+ var existingPerson1 = new PersonBuilder("Joe Shmo").Build();
+ var existingPerson2 = new PersonBuilder("Jane Doe").Build();
+ var chapter = new ChapterBuilder("1")
+ .WithPerson(existingPerson1, PersonRole.Editor)
+ .WithPerson(existingPerson2, PersonRole.Editor)
+ .Build();
+
+ var series = new SeriesBuilder("Test 1")
+ .WithLibraryId(library.Id)
+ .WithVolume(new VolumeBuilder("1")
+ .WithChapter(chapter)
+ .Build())
+ .Build();
+
+ UnitOfWork.SeriesRepository.Add(series);
+ await UnitOfWork.CommitAsync();
+
+ // Call UpdateChapterPeopleAsync with only one person
+ await PersonHelper.UpdateChapterPeopleAsync(chapter, new List { "Joe Shmo" }, PersonRole.Editor, UnitOfWork);
+
+ // PersonHelper does not remove the Person from the global DbSet itself
+ await UnitOfWork.PersonRepository.RemoveAllPeopleNoLongerAssociated();
+
+ var people = await UnitOfWork.PersonRepository.GetAllPeople();
+ Assert.DoesNotContain(people, p => p.Name == "Jane Doe");
+
+ var chapterPeople = chapter.People.Select(cp => cp.Person.Name).ToList();
+ Assert.Contains("Joe Shmo", chapterPeople);
+ Assert.DoesNotContain("Jane Doe", chapterPeople);
+ }
+
+ // 3. Test no changes when the list of people is the same
+ [Fact]
+ public async Task UpdateChapterPeopleAsync_NoChanges()
+ {
+ await ResetDb();
+
+ var library = new LibraryBuilder("My Library")
+ .Build();
+
+ UnitOfWork.LibraryRepository.Add(library);
+ await UnitOfWork.CommitAsync();
+
+ var existingPerson = new PersonBuilder("Joe Shmo").Build();
+ var chapter = new ChapterBuilder("1").WithPerson(existingPerson, PersonRole.Editor).Build();
+
+ var series = new SeriesBuilder("Test 1")
+ .WithLibraryId(library.Id)
+ .WithVolume(new VolumeBuilder("1")
+ .WithChapter(chapter)
+ .Build())
+ .Build();
+
+ UnitOfWork.SeriesRepository.Add(series);
+ await UnitOfWork.CommitAsync();
+
+ // Call UpdateChapterPeopleAsync with the same list
+ await PersonHelper.UpdateChapterPeopleAsync(chapter, new List { "Joe Shmo" }, PersonRole.Editor, UnitOfWork);
+
+ var people = await UnitOfWork.PersonRepository.GetAllPeople();
+ Assert.Contains(people, p => p.Name == "Joe Shmo");
+
+ var chapterPeople = chapter.People.Select(cp => cp.Person.Name).ToList();
+ Assert.Contains("Joe Shmo", chapterPeople);
+ Assert.Single(chapter.People); // No duplicate entries
+ }
+
+ // 4. Test multiple roles for a person
+ [Fact]
+ public async Task UpdateChapterPeopleAsync_MultipleRoles()
+ {
+ await ResetDb();
+
+ var library = new LibraryBuilder("My Library")
+ .Build();
+
+ UnitOfWork.LibraryRepository.Add(library);
+ await UnitOfWork.CommitAsync();
+
+ var person = new PersonBuilder("Joe Shmo").Build();
+ var chapter = new ChapterBuilder("1").WithPerson(person, PersonRole.Writer).Build();
+
+ var series = new SeriesBuilder("Test 1")
+ .WithLibraryId(library.Id)
+ .WithVolume(new VolumeBuilder("1")
+ .WithChapter(chapter)
+ .Build())
+ .Build();
+
+ UnitOfWork.SeriesRepository.Add(series);
+ await UnitOfWork.CommitAsync();
+
+ // Add same person as Editor
+ await PersonHelper.UpdateChapterPeopleAsync(chapter, new List { "Joe Shmo" }, PersonRole.Editor, UnitOfWork);
+
+ // Ensure that the same person is assigned with two roles
+ var chapterPeople = chapter
+ .People
+ .Where(cp =>
+ cp.Person.Name == "Joe Shmo")
+ .ToList();
+ Assert.Equal(2, chapterPeople.Count); // One for each role
+ Assert.Contains(chapterPeople, cp => cp.Role == PersonRole.Writer);
+ Assert.Contains(chapterPeople, cp => cp.Role == PersonRole.Editor);
+ }
+
+ [Fact]
+ public async Task UpdateChapterPeopleAsync_MatchOnAlias_NoChanges()
+ {
+ await ResetDb();
+
+ var library = new LibraryBuilder("My Library")
+ .Build();
+
+ UnitOfWork.LibraryRepository.Add(library);
+ await UnitOfWork.CommitAsync();
+
+ var person = new PersonBuilder("Joe Doe")
+ .WithAlias("Jonny Doe")
+ .Build();
+
+ var chapter = new ChapterBuilder("1")
+ .WithPerson(person, PersonRole.Editor)
+ .Build();
+
+ var series = new SeriesBuilder("Test 1")
+ .WithLibraryId(library.Id)
+ .WithVolume(new VolumeBuilder("1")
+ .WithChapter(chapter)
+ .Build())
+ .Build();
+
+ UnitOfWork.SeriesRepository.Add(series);
+ await UnitOfWork.CommitAsync();
+
+ // Add on Name
+ await PersonHelper.UpdateChapterPeopleAsync(chapter, new List { "Joe Doe" }, PersonRole.Editor, UnitOfWork);
+ await UnitOfWork.CommitAsync();
+
+ var allPeople = await UnitOfWork.PersonRepository.GetAllPeople();
+ Assert.Single(allPeople);
+
+ // Add on alias
+ await PersonHelper.UpdateChapterPeopleAsync(chapter, new List { "Jonny Doe" }, PersonRole.Editor, UnitOfWork);
+ await UnitOfWork.CommitAsync();
+
+ allPeople = await UnitOfWork.PersonRepository.GetAllPeople();
+ Assert.Single(allPeople);
+ }
+
+ // TODO: Unit tests for series
}
diff --git a/API.Tests/Helpers/RandfHelper.cs b/API.Tests/Helpers/RandfHelper.cs
new file mode 100644
index 000000000..d8c007df7
--- /dev/null
+++ b/API.Tests/Helpers/RandfHelper.cs
@@ -0,0 +1,124 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+
+namespace API.Tests.Helpers;
+
+public class RandfHelper
+{
+ private static readonly Random Random = new ();
+
+ ///
+ /// Returns true if all simple fields are equal
+ ///
+ ///
+ ///
+ /// fields to ignore, note that the names are very weird sometimes
+ ///
+ ///
+ ///
+ public static bool AreSimpleFieldsEqual(object obj1, object obj2, IList ignoreFields)
+ {
+ if (obj1 == null || obj2 == null)
+ throw new ArgumentNullException("Neither object can be null.");
+
+ Type type1 = obj1.GetType();
+ Type type2 = obj2.GetType();
+
+ if (type1 != type2)
+ throw new ArgumentException("Objects must be of the same type.");
+
+ FieldInfo[] fields = type1.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
+
+ foreach (var field in fields)
+ {
+ if (field.IsInitOnly) continue;
+ if (ignoreFields.Contains(field.Name)) continue;
+
+ Type fieldType = field.FieldType;
+
+ if (IsRelevantType(fieldType))
+ {
+ object value1 = field.GetValue(obj1);
+ object value2 = field.GetValue(obj2);
+
+ if (!Equals(value1, value2))
+ {
+ throw new ArgumentException("Fields must be of the same type: " + field.Name + " was " + value1 + " and " + value2);
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private static bool IsRelevantType(Type type)
+ {
+ return type.IsPrimitive
+ || type == typeof(string)
+ || type.IsEnum;
+ }
+
+ ///
+ /// Sets all simple fields of the given object to a random value
+ ///
+ ///
+ /// Simple is, primitive, string, or enum
+ ///
+ public static void SetRandomValues(object obj)
+ {
+ if (obj == null) throw new ArgumentNullException(nameof(obj));
+
+ Type type = obj.GetType();
+ FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+
+ foreach (var field in fields)
+ {
+ if (field.IsInitOnly) continue; // Skip readonly fields
+
+ object value = GenerateRandomValue(field.FieldType);
+ if (value != null)
+ {
+ field.SetValue(obj, value);
+ }
+ }
+ }
+
+ private static object GenerateRandomValue(Type type)
+ {
+ if (type == typeof(int))
+ return Random.Next();
+ if (type == typeof(float))
+ return (float)Random.NextDouble() * 100;
+ if (type == typeof(double))
+ return Random.NextDouble() * 100;
+ if (type == typeof(bool))
+ return Random.Next(2) == 1;
+ if (type == typeof(char))
+ return (char)Random.Next('A', 'Z' + 1);
+ if (type == typeof(byte))
+ return (byte)Random.Next(0, 256);
+ if (type == typeof(short))
+ return (short)Random.Next(short.MinValue, short.MaxValue);
+ if (type == typeof(long))
+ return (long)(Random.NextDouble() * long.MaxValue);
+ if (type == typeof(string))
+ return GenerateRandomString(10);
+ if (type.IsEnum)
+ {
+ var values = Enum.GetValues(type);
+ return values.GetValue(Random.Next(values.Length));
+ }
+
+ // Unsupported type
+ return null;
+ }
+
+ private static string GenerateRandomString(int length)
+ {
+ const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+ return new string(Enumerable.Repeat(chars, length)
+ .Select(s => s[Random.Next(s.Length)]).ToArray());
+ }
+}
diff --git a/API.Tests/Parsers/ComicVineParserTests.cs b/API.Tests/Parsers/ComicVineParserTests.cs
index f01e98afd..2f4fd568e 100644
--- a/API.Tests/Parsers/ComicVineParserTests.cs
+++ b/API.Tests/Parsers/ComicVineParserTests.cs
@@ -36,7 +36,7 @@ public class ComicVineParserTests
public void Parse_SeriesWithComicInfo()
{
var actual = _parser.Parse("C:/Comics/Birds of Prey (2002)/Birds of Prey 001 (2002).cbz", "C:/Comics/Birds of Prey (2002)/",
- RootDirectory, LibraryType.ComicVine, new ComicInfo()
+ RootDirectory, LibraryType.ComicVine, true, new ComicInfo()
{
Series = "Birds of Prey",
Volume = "2002"
@@ -54,7 +54,7 @@ public class ComicVineParserTests
public void Parse_SeriesWithDirectoryNameAsSeriesYear()
{
var actual = _parser.Parse("C:/Comics/Birds of Prey (2002)/Birds of Prey 001 (2002).cbz", "C:/Comics/Birds of Prey (2002)/",
- RootDirectory, LibraryType.ComicVine, null);
+ RootDirectory, LibraryType.ComicVine, true, null);
Assert.NotNull(actual);
Assert.Equal("Birds of Prey (2002)", actual.Series);
@@ -69,7 +69,7 @@ public class ComicVineParserTests
public void Parse_SeriesWithADirectoryNameAsSeriesYear()
{
var actual = _parser.Parse("C:/Comics/DC Comics/Birds of Prey (1999)/Birds of Prey 001 (1999).cbz", "C:/Comics/DC Comics/",
- RootDirectory, LibraryType.ComicVine, null);
+ RootDirectory, LibraryType.ComicVine, true, null);
Assert.NotNull(actual);
Assert.Equal("Birds of Prey (1999)", actual.Series);
@@ -84,7 +84,7 @@ public class ComicVineParserTests
public void Parse_FallbackToDirectoryNameOnly()
{
var actual = _parser.Parse("C:/Comics/DC Comics/Blood Syndicate/Blood Syndicate 001 (1999).cbz", "C:/Comics/DC Comics/",
- RootDirectory, LibraryType.ComicVine, null);
+ RootDirectory, LibraryType.ComicVine, true, null);
Assert.NotNull(actual);
Assert.Equal("Blood Syndicate", actual.Series);
diff --git a/API.Tests/Parsers/DefaultParserTests.cs b/API.Tests/Parsers/DefaultParserTests.cs
index 733b55d62..244c08b97 100644
--- a/API.Tests/Parsers/DefaultParserTests.cs
+++ b/API.Tests/Parsers/DefaultParserTests.cs
@@ -33,7 +33,7 @@ public class DefaultParserTests
[InlineData("C:/", "C:/Something Random/Mujaki no Rakuen SP01.cbz", "Something Random")]
public void ParseFromFallbackFolders_FallbackShouldParseSeries(string rootDir, string inputPath, string expectedSeries)
{
- var actual = _defaultParser.Parse(inputPath, rootDir, rootDir, LibraryType.Manga, null);
+ var actual = _defaultParser.Parse(inputPath, rootDir, rootDir, LibraryType.Manga, true, null);
if (actual == null)
{
Assert.NotNull(actual);
@@ -74,7 +74,7 @@ public class DefaultParserTests
fs.AddFile(inputFile, new MockFileData(""));
var ds = new DirectoryService(Substitute.For>(), fs);
var parser = new BasicParser(ds, new ImageParser(ds));
- var actual = parser.Parse(inputFile, rootDirectory, rootDirectory, LibraryType.Manga, null);
+ var actual = parser.Parse(inputFile, rootDirectory, rootDirectory, LibraryType.Manga, true, null);
_defaultParser.ParseFromFallbackFolders(inputFile, rootDirectory, LibraryType.Manga, ref actual);
Assert.Equal(expectedParseInfo, actual.Series);
}
@@ -90,7 +90,7 @@ public class DefaultParserTests
fs.AddFile(inputFile, new MockFileData(""));
var ds = new DirectoryService(Substitute.For>(), fs);
var parser = new BasicParser(ds, new ImageParser(ds));
- var actual = parser.Parse(inputFile, rootDirectory, rootDirectory, LibraryType.Manga, null);
+ var actual = parser.Parse(inputFile, rootDirectory, rootDirectory, LibraryType.Manga, true, null);
_defaultParser.ParseFromFallbackFolders(inputFile, rootDirectory, LibraryType.Manga, ref actual);
Assert.Equal(expectedParseInfo, actual.Series);
}
@@ -251,7 +251,7 @@ public class DefaultParserTests
foreach (var file in expected.Keys)
{
var expectedInfo = expected[file];
- var actual = _defaultParser.Parse(file, rootPath, rootPath, LibraryType.Manga, null);
+ var actual = _defaultParser.Parse(file, rootPath, rootPath, LibraryType.Manga, true, null);
if (expectedInfo == null)
{
Assert.Null(actual);
@@ -289,7 +289,7 @@ public class DefaultParserTests
Chapters = "8", Filename = "13.jpg", Format = MangaFormat.Image,
FullFilePath = filepath, IsSpecial = false
};
- var actual2 = _defaultParser.Parse(filepath, @"E:/Manga/Monster #8", "E:/Manga", LibraryType.Manga, null);
+ var actual2 = _defaultParser.Parse(filepath, @"E:/Manga/Monster #8", "E:/Manga", LibraryType.Manga, true, null);
Assert.NotNull(actual2);
_testOutputHelper.WriteLine($"Validating {filepath}");
Assert.Equal(expectedInfo2.Format, actual2.Format);
@@ -315,7 +315,7 @@ public class DefaultParserTests
FullFilePath = filepath, IsSpecial = false
};
- actual2 = _defaultParser.Parse(filepath, @"E:/Manga/Extra layer for no reason/", "E:/Manga",LibraryType.Manga, null);
+ actual2 = _defaultParser.Parse(filepath, @"E:/Manga/Extra layer for no reason/", "E:/Manga",LibraryType.Manga, true, null);
Assert.NotNull(actual2);
_testOutputHelper.WriteLine($"Validating {filepath}");
Assert.Equal(expectedInfo2.Format, actual2.Format);
@@ -341,7 +341,7 @@ public class DefaultParserTests
FullFilePath = filepath, IsSpecial = false
};
- actual2 = _defaultParser.Parse(filepath, @"E:/Manga/Extra layer for no reason/", "E:/Manga", LibraryType.Manga, null);
+ actual2 = _defaultParser.Parse(filepath, @"E:/Manga/Extra layer for no reason/", "E:/Manga", LibraryType.Manga, true, null);
Assert.NotNull(actual2);
_testOutputHelper.WriteLine($"Validating {filepath}");
Assert.Equal(expectedInfo2.Format, actual2.Format);
@@ -383,7 +383,7 @@ public class DefaultParserTests
FullFilePath = filepath
};
- var actual = parser.Parse(filepath, rootPath, rootPath, LibraryType.Manga, null);
+ var actual = parser.Parse(filepath, rootPath, rootPath, LibraryType.Manga, true, null);
Assert.NotNull(actual);
_testOutputHelper.WriteLine($"Validating {filepath}");
@@ -412,7 +412,7 @@ public class DefaultParserTests
FullFilePath = filepath
};
- actual = parser.Parse(filepath, rootPath, rootPath, LibraryType.Manga, null);
+ actual = parser.Parse(filepath, rootPath, rootPath, LibraryType.Manga, true, null);
Assert.NotNull(actual);
_testOutputHelper.WriteLine($"Validating {filepath}");
Assert.Equal(expected.Format, actual.Format);
@@ -475,7 +475,7 @@ public class DefaultParserTests
foreach (var file in expected.Keys)
{
var expectedInfo = expected[file];
- var actual = _defaultParser.Parse(file, rootPath, rootPath, LibraryType.Comic, null);
+ var actual = _defaultParser.Parse(file, rootPath, rootPath, LibraryType.Comic, true, null);
if (expectedInfo == null)
{
Assert.Null(actual);
diff --git a/API.Tests/Parsers/ImageParserTests.cs b/API.Tests/Parsers/ImageParserTests.cs
index f95c98ddf..63df1926e 100644
--- a/API.Tests/Parsers/ImageParserTests.cs
+++ b/API.Tests/Parsers/ImageParserTests.cs
@@ -34,7 +34,7 @@ public class ImageParserTests
public void Parse_SeriesWithDirectoryName()
{
var actual = _parser.Parse("C:/Comics/Birds of Prey/Chapter 01/01.jpg", "C:/Comics/Birds of Prey/",
- RootDirectory, LibraryType.Image, null);
+ RootDirectory, LibraryType.Image, true, null);
Assert.NotNull(actual);
Assert.Equal("Birds of Prey", actual.Series);
@@ -48,7 +48,7 @@ public class ImageParserTests
public void Parse_SeriesWithNoNestedChapter()
{
var actual = _parser.Parse("C:/Comics/Birds of Prey/Chapter 01 page 01.jpg", "C:/Comics/",
- RootDirectory, LibraryType.Image, null);
+ RootDirectory, LibraryType.Image, true, null);
Assert.NotNull(actual);
Assert.Equal("Birds of Prey", actual.Series);
@@ -62,7 +62,7 @@ public class ImageParserTests
public void Parse_SeriesWithLooseImages()
{
var actual = _parser.Parse("C:/Comics/Birds of Prey/page 01.jpg", "C:/Comics/",
- RootDirectory, LibraryType.Image, null);
+ RootDirectory, LibraryType.Image, true, null);
Assert.NotNull(actual);
Assert.Equal("Birds of Prey", actual.Series);
diff --git a/API.Tests/Parsers/PdfParserTests.cs b/API.Tests/Parsers/PdfParserTests.cs
index 72088526d..08bf9f25d 100644
--- a/API.Tests/Parsers/PdfParserTests.cs
+++ b/API.Tests/Parsers/PdfParserTests.cs
@@ -35,7 +35,7 @@ public class PdfParserTests
{
var actual = _parser.Parse("C:/Books/A Dictionary of Japanese Food - Ingredients and Culture/A Dictionary of Japanese Food - Ingredients and Culture.pdf",
"C:/Books/A Dictionary of Japanese Food - Ingredients and Culture/",
- RootDirectory, LibraryType.Book, null);
+ RootDirectory, LibraryType.Book, true, null);
Assert.NotNull(actual);
Assert.Equal("A Dictionary of Japanese Food - Ingredients and Culture", actual.Series);
diff --git a/API.Tests/Parsing/ImageParsingTests.cs b/API.Tests/Parsing/ImageParsingTests.cs
index 3d78d9372..362b4b08c 100644
--- a/API.Tests/Parsing/ImageParsingTests.cs
+++ b/API.Tests/Parsing/ImageParsingTests.cs
@@ -34,7 +34,7 @@ public class ImageParsingTests
Chapters = "8", Filename = "13.jpg", Format = MangaFormat.Image,
FullFilePath = filepath, IsSpecial = false
};
- var actual2 = _parser.Parse(filepath, @"E:\Manga\Monster #8", "E:/Manga", LibraryType.Image, null);
+ var actual2 = _parser.Parse(filepath, @"E:\Manga\Monster #8", "E:/Manga", LibraryType.Image, true, null);
Assert.NotNull(actual2);
_testOutputHelper.WriteLine($"Validating {filepath}");
Assert.Equal(expectedInfo2.Format, actual2.Format);
@@ -60,7 +60,7 @@ public class ImageParsingTests
FullFilePath = filepath, IsSpecial = false
};
- actual2 = _parser.Parse(filepath, @"E:\Manga\Extra layer for no reason\", "E:/Manga", LibraryType.Image, null);
+ actual2 = _parser.Parse(filepath, @"E:\Manga\Extra layer for no reason\", "E:/Manga", LibraryType.Image, true, null);
Assert.NotNull(actual2);
_testOutputHelper.WriteLine($"Validating {filepath}");
Assert.Equal(expectedInfo2.Format, actual2.Format);
@@ -86,7 +86,7 @@ public class ImageParsingTests
FullFilePath = filepath, IsSpecial = false
};
- actual2 = _parser.Parse(filepath, @"E:\Manga\Extra layer for no reason\", "E:/Manga", LibraryType.Image, null);
+ actual2 = _parser.Parse(filepath, @"E:\Manga\Extra layer for no reason\", "E:/Manga", LibraryType.Image, true, null);
Assert.NotNull(actual2);
_testOutputHelper.WriteLine($"Validating {filepath}");
Assert.Equal(expectedInfo2.Format, actual2.Format);
diff --git a/API.Tests/Parsing/MangaParsingTests.cs b/API.Tests/Parsing/MangaParsingTests.cs
index 8b93c5f90..53f2bc4c9 100644
--- a/API.Tests/Parsing/MangaParsingTests.cs
+++ b/API.Tests/Parsing/MangaParsingTests.cs
@@ -68,10 +68,8 @@ public class MangaParsingTests
[InlineData("Манга Тома 1-4", "1-4")]
[InlineData("Манга Том 1-4", "1-4")]
[InlineData("조선왕조실톡 106화", "106")]
- [InlineData("죽음 13회", "13")]
[InlineData("동의보감 13장", "13")]
[InlineData("몰?루 아카이브 7.5권", "7.5")]
- [InlineData("주술회전 1.5권", "1.5")]
[InlineData("63권#200", "63")]
[InlineData("시즌34삽화2", "34")]
[InlineData("Accel World Chapter 001 Volume 002", "2")]
diff --git a/API.Tests/Repository/GenreRepositoryTests.cs b/API.Tests/Repository/GenreRepositoryTests.cs
new file mode 100644
index 000000000..d197a91ba
--- /dev/null
+++ b/API.Tests/Repository/GenreRepositoryTests.cs
@@ -0,0 +1,280 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using API.DTOs.Metadata.Browse;
+using API.Entities;
+using API.Entities.Enums;
+using API.Entities.Metadata;
+using API.Helpers;
+using API.Helpers.Builders;
+using Xunit;
+
+namespace API.Tests.Repository;
+
+public class GenreRepositoryTests : AbstractDbTest
+{
+ private AppUser _fullAccess;
+ private AppUser _restrictedAccess;
+ private AppUser _restrictedAgeAccess;
+
+ protected override async Task ResetDb()
+ {
+ Context.Genre.RemoveRange(Context.Genre);
+ Context.Library.RemoveRange(Context.Library);
+ await Context.SaveChangesAsync();
+ }
+
+ private TestGenreSet CreateTestGenres()
+ {
+ return new TestGenreSet
+ {
+ SharedSeriesChaptersGenre = new GenreBuilder("Shared Series Chapter Genre").Build(),
+ SharedSeriesGenre = new GenreBuilder("Shared Series Genre").Build(),
+ SharedChaptersGenre = new GenreBuilder("Shared Chapters Genre").Build(),
+ Lib0SeriesChaptersGenre = new GenreBuilder("Lib0 Series Chapter Genre").Build(),
+ Lib0SeriesGenre = new GenreBuilder("Lib0 Series Genre").Build(),
+ Lib0ChaptersGenre = new GenreBuilder("Lib0 Chapters Genre").Build(),
+ Lib1SeriesChaptersGenre = new GenreBuilder("Lib1 Series Chapter Genre").Build(),
+ Lib1SeriesGenre = new GenreBuilder("Lib1 Series Genre").Build(),
+ Lib1ChaptersGenre = new GenreBuilder("Lib1 Chapters Genre").Build(),
+ Lib1ChapterAgeGenre = new GenreBuilder("Lib1 Chapter Age Genre").Build()
+ };
+ }
+
+ private async Task SeedDbWithGenres(TestGenreSet genres)
+ {
+ await CreateTestUsers();
+ await AddGenresToContext(genres);
+ await CreateLibrariesWithGenres(genres);
+ await AssignLibrariesToUsers();
+ }
+
+ private async Task CreateTestUsers()
+ {
+ _fullAccess = new AppUserBuilder("amelia", "amelia@example.com").Build();
+ _restrictedAccess = new AppUserBuilder("mila", "mila@example.com").Build();
+ _restrictedAgeAccess = new AppUserBuilder("eva", "eva@example.com").Build();
+ _restrictedAgeAccess.AgeRestriction = AgeRating.Teen;
+ _restrictedAgeAccess.AgeRestrictionIncludeUnknowns = true;
+
+ Context.Users.Add(_fullAccess);
+ Context.Users.Add(_restrictedAccess);
+ Context.Users.Add(_restrictedAgeAccess);
+ await Context.SaveChangesAsync();
+ }
+
+ private async Task AddGenresToContext(TestGenreSet genres)
+ {
+ var allGenres = genres.GetAllGenres();
+ Context.Genre.AddRange(allGenres);
+ await Context.SaveChangesAsync();
+ }
+
+ private async Task CreateLibrariesWithGenres(TestGenreSet genres)
+ {
+ var lib0 = new LibraryBuilder("lib0")
+ .WithSeries(new SeriesBuilder("lib0-s0")
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithGenres([genres.SharedSeriesChaptersGenre, genres.SharedSeriesGenre, genres.Lib0SeriesChaptersGenre, genres.Lib0SeriesGenre])
+ .Build())
+ .WithVolume(new VolumeBuilder("1")
+ .WithChapter(new ChapterBuilder("1")
+ .WithGenres([genres.SharedSeriesChaptersGenre, genres.SharedChaptersGenre, genres.Lib0SeriesChaptersGenre, genres.Lib0ChaptersGenre])
+ .Build())
+ .WithChapter(new ChapterBuilder("2")
+ .WithGenres([genres.SharedSeriesChaptersGenre, genres.SharedChaptersGenre, genres.Lib1SeriesChaptersGenre, genres.Lib1ChaptersGenre])
+ .Build())
+ .Build())
+ .Build())
+ .Build();
+
+ var lib1 = new LibraryBuilder("lib1")
+ .WithSeries(new SeriesBuilder("lib1-s0")
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithGenres([genres.SharedSeriesChaptersGenre, genres.SharedSeriesGenre, genres.Lib1SeriesChaptersGenre, genres.Lib1SeriesGenre])
+ .WithAgeRating(AgeRating.Mature17Plus)
+ .Build())
+ .WithVolume(new VolumeBuilder("1")
+ .WithChapter(new ChapterBuilder("1")
+ .WithGenres([genres.SharedSeriesChaptersGenre, genres.SharedChaptersGenre, genres.Lib1SeriesChaptersGenre, genres.Lib1ChaptersGenre])
+ .Build())
+ .WithChapter(new ChapterBuilder("2")
+ .WithGenres([genres.SharedSeriesChaptersGenre, genres.SharedChaptersGenre, genres.Lib1SeriesChaptersGenre, genres.Lib1ChaptersGenre, genres.Lib1ChapterAgeGenre])
+ .WithAgeRating(AgeRating.Mature17Plus)
+ .Build())
+ .Build())
+ .Build())
+ .WithSeries(new SeriesBuilder("lib1-s1")
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithGenres([genres.SharedSeriesChaptersGenre, genres.SharedSeriesGenre, genres.Lib1SeriesChaptersGenre, genres.Lib1SeriesGenre])
+ .Build())
+ .WithVolume(new VolumeBuilder("1")
+ .WithChapter(new ChapterBuilder("1")
+ .WithGenres([genres.SharedSeriesChaptersGenre, genres.SharedChaptersGenre, genres.Lib1SeriesChaptersGenre, genres.Lib1ChaptersGenre])
+ .Build())
+ .WithChapter(new ChapterBuilder("2")
+ .WithGenres([genres.SharedSeriesChaptersGenre, genres.SharedChaptersGenre, genres.Lib1SeriesChaptersGenre, genres.Lib1ChaptersGenre])
+ .Build())
+ .Build())
+ .Build())
+ .Build();
+
+ Context.Library.Add(lib0);
+ Context.Library.Add(lib1);
+ await Context.SaveChangesAsync();
+ }
+
+ private async Task AssignLibrariesToUsers()
+ {
+ var lib0 = Context.Library.First(l => l.Name == "lib0");
+ var lib1 = Context.Library.First(l => l.Name == "lib1");
+
+ _fullAccess.Libraries.Add(lib0);
+ _fullAccess.Libraries.Add(lib1);
+ _restrictedAccess.Libraries.Add(lib1);
+ _restrictedAgeAccess.Libraries.Add(lib1);
+
+ await Context.SaveChangesAsync();
+ }
+
+ private static Predicate ContainsGenreCheck(Genre genre)
+ {
+ return g => g.Id == genre.Id;
+ }
+
+ private static void AssertGenrePresent(IEnumerable genres, Genre expectedGenre)
+ {
+ Assert.Contains(genres, ContainsGenreCheck(expectedGenre));
+ }
+
+ private static void AssertGenreNotPresent(IEnumerable genres, Genre expectedGenre)
+ {
+ Assert.DoesNotContain(genres, ContainsGenreCheck(expectedGenre));
+ }
+
+ private static BrowseGenreDto GetGenreDto(IEnumerable genres, Genre genre)
+ {
+ return genres.First(dto => dto.Id == genre.Id);
+ }
+
+ [Fact]
+ public async Task GetBrowseableGenre_FullAccess_ReturnsAllGenresWithCorrectCounts()
+ {
+ // Arrange
+ await ResetDb();
+ var genres = CreateTestGenres();
+ await SeedDbWithGenres(genres);
+
+ // Act
+ var fullAccessGenres = await UnitOfWork.GenreRepository.GetBrowseableGenre(_fullAccess.Id, new UserParams());
+
+ // Assert
+ Assert.Equal(genres.GetAllGenres().Count, fullAccessGenres.TotalCount);
+
+ foreach (var genre in genres.GetAllGenres())
+ {
+ AssertGenrePresent(fullAccessGenres, genre);
+ }
+
+ // Verify counts - 1 lib0 series, 2 lib1 series = 3 total series
+ Assert.Equal(3, GetGenreDto(fullAccessGenres, genres.SharedSeriesChaptersGenre).SeriesCount);
+ Assert.Equal(6, GetGenreDto(fullAccessGenres, genres.SharedSeriesChaptersGenre).ChapterCount);
+ Assert.Equal(1, GetGenreDto(fullAccessGenres, genres.Lib0SeriesGenre).SeriesCount);
+ }
+
+ [Fact]
+ public async Task GetBrowseableGenre_RestrictedAccess_ReturnsOnlyAccessibleGenres()
+ {
+ // Arrange
+ await ResetDb();
+ var genres = CreateTestGenres();
+ await SeedDbWithGenres(genres);
+
+ // Act
+ var restrictedAccessGenres = await UnitOfWork.GenreRepository.GetBrowseableGenre(_restrictedAccess.Id, new UserParams());
+
+ // Assert - Should see: 3 shared + 4 library 1 specific = 7 genres
+ Assert.Equal(7, restrictedAccessGenres.TotalCount);
+
+ // Verify shared and Library 1 genres are present
+ AssertGenrePresent(restrictedAccessGenres, genres.SharedSeriesChaptersGenre);
+ AssertGenrePresent(restrictedAccessGenres, genres.SharedSeriesGenre);
+ AssertGenrePresent(restrictedAccessGenres, genres.SharedChaptersGenre);
+ AssertGenrePresent(restrictedAccessGenres, genres.Lib1SeriesChaptersGenre);
+ AssertGenrePresent(restrictedAccessGenres, genres.Lib1SeriesGenre);
+ AssertGenrePresent(restrictedAccessGenres, genres.Lib1ChaptersGenre);
+ AssertGenrePresent(restrictedAccessGenres, genres.Lib1ChapterAgeGenre);
+
+ // Verify Library 0 specific genres are not present
+ AssertGenreNotPresent(restrictedAccessGenres, genres.Lib0SeriesChaptersGenre);
+ AssertGenreNotPresent(restrictedAccessGenres, genres.Lib0SeriesGenre);
+ AssertGenreNotPresent(restrictedAccessGenres, genres.Lib0ChaptersGenre);
+
+ // Verify counts - 2 lib1 series
+ Assert.Equal(2, GetGenreDto(restrictedAccessGenres, genres.SharedSeriesChaptersGenre).SeriesCount);
+ Assert.Equal(4, GetGenreDto(restrictedAccessGenres, genres.SharedSeriesChaptersGenre).ChapterCount);
+ Assert.Equal(2, GetGenreDto(restrictedAccessGenres, genres.Lib1SeriesGenre).SeriesCount);
+ Assert.Equal(4, GetGenreDto(restrictedAccessGenres, genres.Lib1ChaptersGenre).ChapterCount);
+ Assert.Equal(1, GetGenreDto(restrictedAccessGenres, genres.Lib1ChapterAgeGenre).ChapterCount);
+ }
+
+ [Fact]
+ public async Task GetBrowseableGenre_RestrictedAgeAccess_FiltersAgeRestrictedContent()
+ {
+ // Arrange
+ await ResetDb();
+ var genres = CreateTestGenres();
+ await SeedDbWithGenres(genres);
+
+ // Act
+ var restrictedAgeAccessGenres = await UnitOfWork.GenreRepository.GetBrowseableGenre(_restrictedAgeAccess.Id, new UserParams());
+
+ // Assert - Should see: 3 shared + 3 lib1 specific = 6 genres (age-restricted genre filtered out)
+ Assert.Equal(6, restrictedAgeAccessGenres.TotalCount);
+
+ // Verify accessible genres are present
+ AssertGenrePresent(restrictedAgeAccessGenres, genres.SharedSeriesChaptersGenre);
+ AssertGenrePresent(restrictedAgeAccessGenres, genres.SharedSeriesGenre);
+ AssertGenrePresent(restrictedAgeAccessGenres, genres.SharedChaptersGenre);
+ AssertGenrePresent(restrictedAgeAccessGenres, genres.Lib1SeriesChaptersGenre);
+ AssertGenrePresent(restrictedAgeAccessGenres, genres.Lib1SeriesGenre);
+ AssertGenrePresent(restrictedAgeAccessGenres, genres.Lib1ChaptersGenre);
+
+ // Verify age-restricted genre is filtered out
+ AssertGenreNotPresent(restrictedAgeAccessGenres, genres.Lib1ChapterAgeGenre);
+
+ // Verify counts - 1 series lib1 (age-restricted series filtered out)
+ Assert.Equal(1, GetGenreDto(restrictedAgeAccessGenres, genres.SharedSeriesChaptersGenre).SeriesCount);
+ Assert.Equal(1, GetGenreDto(restrictedAgeAccessGenres, genres.Lib1SeriesGenre).SeriesCount);
+
+ // These values represent a bug - chapters are not properly filtered when their series is age-restricted
+ // Should be 2, but currently returns 3 due to the filtering issue
+ Assert.Equal(3, GetGenreDto(restrictedAgeAccessGenres, genres.SharedSeriesChaptersGenre).ChapterCount);
+ Assert.Equal(3, GetGenreDto(restrictedAgeAccessGenres, genres.Lib1ChaptersGenre).ChapterCount);
+ }
+
+ private class TestGenreSet
+ {
+ public Genre SharedSeriesChaptersGenre { get; set; }
+ public Genre SharedSeriesGenre { get; set; }
+ public Genre SharedChaptersGenre { get; set; }
+ public Genre Lib0SeriesChaptersGenre { get; set; }
+ public Genre Lib0SeriesGenre { get; set; }
+ public Genre Lib0ChaptersGenre { get; set; }
+ public Genre Lib1SeriesChaptersGenre { get; set; }
+ public Genre Lib1SeriesGenre { get; set; }
+ public Genre Lib1ChaptersGenre { get; set; }
+ public Genre Lib1ChapterAgeGenre { get; set; }
+
+ public List GetAllGenres()
+ {
+ return
+ [
+ SharedSeriesChaptersGenre, SharedSeriesGenre, SharedChaptersGenre,
+ Lib0SeriesChaptersGenre, Lib0SeriesGenre, Lib0ChaptersGenre,
+ Lib1SeriesChaptersGenre, Lib1SeriesGenre, Lib1ChaptersGenre, Lib1ChapterAgeGenre
+ ];
+ }
+ }
+}
diff --git a/API.Tests/Repository/PersonRepositoryTests.cs b/API.Tests/Repository/PersonRepositoryTests.cs
new file mode 100644
index 000000000..a2b19cc0c
--- /dev/null
+++ b/API.Tests/Repository/PersonRepositoryTests.cs
@@ -0,0 +1,342 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using API.DTOs.Metadata.Browse;
+using API.DTOs.Metadata.Browse.Requests;
+using API.Entities;
+using API.Entities.Enums;
+using API.Entities.Person;
+using API.Helpers;
+using API.Helpers.Builders;
+using Xunit;
+
+namespace API.Tests.Repository;
+
+public class PersonRepositoryTests : AbstractDbTest
+{
+ private AppUser _fullAccess;
+ private AppUser _restrictedAccess;
+ private AppUser _restrictedAgeAccess;
+
+ protected override async Task ResetDb()
+ {
+ Context.Person.RemoveRange(Context.Person.ToList());
+ Context.Library.RemoveRange(Context.Library.ToList());
+ Context.AppUser.RemoveRange(Context.AppUser.ToList());
+ await UnitOfWork.CommitAsync();
+ }
+
+ private async Task SeedDb()
+ {
+ _fullAccess = new AppUserBuilder("amelia", "amelia@example.com").Build();
+ _restrictedAccess = new AppUserBuilder("mila", "mila@example.com").Build();
+ _restrictedAgeAccess = new AppUserBuilder("eva", "eva@example.com").Build();
+ _restrictedAgeAccess.AgeRestriction = AgeRating.Teen;
+ _restrictedAgeAccess.AgeRestrictionIncludeUnknowns = true;
+
+ Context.AppUser.Add(_fullAccess);
+ Context.AppUser.Add(_restrictedAccess);
+ Context.AppUser.Add(_restrictedAgeAccess);
+ await Context.SaveChangesAsync();
+
+ var people = CreateTestPeople();
+ Context.Person.AddRange(people);
+ await Context.SaveChangesAsync();
+
+ var libraries = CreateTestLibraries(people);
+ Context.Library.AddRange(libraries);
+ await Context.SaveChangesAsync();
+
+ _fullAccess.Libraries.Add(libraries[0]); // lib0
+ _fullAccess.Libraries.Add(libraries[1]); // lib1
+ _restrictedAccess.Libraries.Add(libraries[1]); // lib1 only
+ _restrictedAgeAccess.Libraries.Add(libraries[1]); // lib1 only
+
+ await Context.SaveChangesAsync();
+ }
+
+ private static List CreateTestPeople()
+ {
+ return new List
+ {
+ new PersonBuilder("Shared Series Chapter Person").Build(),
+ new PersonBuilder("Shared Series Person").Build(),
+ new PersonBuilder("Shared Chapters Person").Build(),
+ new PersonBuilder("Lib0 Series Chapter Person").Build(),
+ new PersonBuilder("Lib0 Series Person").Build(),
+ new PersonBuilder("Lib0 Chapters Person").Build(),
+ new PersonBuilder("Lib1 Series Chapter Person").Build(),
+ new PersonBuilder("Lib1 Series Person").Build(),
+ new PersonBuilder("Lib1 Chapters Person").Build(),
+ new PersonBuilder("Lib1 Chapter Age Person").Build()
+ };
+ }
+
+ private static List CreateTestLibraries(List people)
+ {
+ var lib0 = new LibraryBuilder("lib0")
+ .WithSeries(new SeriesBuilder("lib0-s0")
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithPerson(GetPersonByName(people, "Shared Series Chapter Person"), PersonRole.Writer)
+ .WithPerson(GetPersonByName(people, "Shared Series Person"), PersonRole.Writer)
+ .WithPerson(GetPersonByName(people, "Lib0 Series Chapter Person"), PersonRole.Writer)
+ .WithPerson(GetPersonByName(people, "Lib0 Series Person"), PersonRole.Writer)
+ .Build())
+ .WithVolume(new VolumeBuilder("1")
+ .WithChapter(new ChapterBuilder("1")
+ .WithPerson(GetPersonByName(people, "Shared Series Chapter Person"), PersonRole.Colorist)
+ .WithPerson(GetPersonByName(people, "Shared Chapters Person"), PersonRole.Colorist)
+ .WithPerson(GetPersonByName(people, "Lib0 Series Chapter Person"), PersonRole.Colorist)
+ .WithPerson(GetPersonByName(people, "Lib0 Chapters Person"), PersonRole.Colorist)
+ .Build())
+ .WithChapter(new ChapterBuilder("2")
+ .WithPerson(GetPersonByName(people, "Shared Series Chapter Person"), PersonRole.Editor)
+ .WithPerson(GetPersonByName(people, "Shared Chapters Person"), PersonRole.Editor)
+ .WithPerson(GetPersonByName(people, "Lib0 Series Chapter Person"), PersonRole.Editor)
+ .WithPerson(GetPersonByName(people, "Lib0 Chapters Person"), PersonRole.Editor)
+ .Build())
+ .Build())
+ .Build())
+ .Build();
+
+ var lib1 = new LibraryBuilder("lib1")
+ .WithSeries(new SeriesBuilder("lib1-s0")
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithPerson(GetPersonByName(people, "Shared Series Chapter Person"), PersonRole.Letterer)
+ .WithPerson(GetPersonByName(people, "Shared Series Person"), PersonRole.Letterer)
+ .WithPerson(GetPersonByName(people, "Lib1 Series Chapter Person"), PersonRole.Letterer)
+ .WithPerson(GetPersonByName(people, "Lib1 Series Person"), PersonRole.Letterer)
+ .WithAgeRating(AgeRating.Mature17Plus)
+ .Build())
+ .WithVolume(new VolumeBuilder("1")
+ .WithChapter(new ChapterBuilder("1")
+ .WithPerson(GetPersonByName(people, "Shared Series Chapter Person"), PersonRole.Imprint)
+ .WithPerson(GetPersonByName(people, "Shared Chapters Person"), PersonRole.Imprint)
+ .WithPerson(GetPersonByName(people, "Lib1 Series Chapter Person"), PersonRole.Imprint)
+ .WithPerson(GetPersonByName(people, "Lib1 Chapters Person"), PersonRole.Imprint)
+ .Build())
+ .WithChapter(new ChapterBuilder("2")
+ .WithPerson(GetPersonByName(people, "Shared Series Chapter Person"), PersonRole.CoverArtist)
+ .WithPerson(GetPersonByName(people, "Shared Chapters Person"), PersonRole.CoverArtist)
+ .WithPerson(GetPersonByName(people, "Lib1 Series Chapter Person"), PersonRole.CoverArtist)
+ .WithPerson(GetPersonByName(people, "Lib1 Chapters Person"), PersonRole.CoverArtist)
+ .WithPerson(GetPersonByName(people, "Lib1 Chapter Age Person"), PersonRole.CoverArtist)
+ .WithAgeRating(AgeRating.Mature17Plus)
+ .Build())
+ .Build())
+ .Build())
+ .WithSeries(new SeriesBuilder("lib1-s1")
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithPerson(GetPersonByName(people, "Shared Series Chapter Person"), PersonRole.Inker)
+ .WithPerson(GetPersonByName(people, "Shared Series Person"), PersonRole.Inker)
+ .WithPerson(GetPersonByName(people, "Lib1 Series Chapter Person"), PersonRole.Inker)
+ .WithPerson(GetPersonByName(people, "Lib1 Series Person"), PersonRole.Inker)
+ .Build())
+ .WithVolume(new VolumeBuilder("1")
+ .WithChapter(new ChapterBuilder("1")
+ .WithPerson(GetPersonByName(people, "Shared Series Chapter Person"), PersonRole.Team)
+ .WithPerson(GetPersonByName(people, "Shared Chapters Person"), PersonRole.Team)
+ .WithPerson(GetPersonByName(people, "Lib1 Series Chapter Person"), PersonRole.Team)
+ .WithPerson(GetPersonByName(people, "Lib1 Chapters Person"), PersonRole.Team)
+ .Build())
+ .WithChapter(new ChapterBuilder("2")
+ .WithPerson(GetPersonByName(people, "Shared Series Chapter Person"), PersonRole.Translator)
+ .WithPerson(GetPersonByName(people, "Shared Chapters Person"), PersonRole.Translator)
+ .WithPerson(GetPersonByName(people, "Lib1 Series Chapter Person"), PersonRole.Translator)
+ .WithPerson(GetPersonByName(people, "Lib1 Chapters Person"), PersonRole.Translator)
+ .Build())
+ .Build())
+ .Build())
+ .Build();
+
+ return new List { lib0, lib1 };
+ }
+
+ private static Person GetPersonByName(List people, string name)
+ {
+ return people.First(p => p.Name == name);
+ }
+
+ private Person GetPersonByName(string name)
+ {
+ return Context.Person.First(p => p.Name == name);
+ }
+
+ private static Predicate ContainsPersonCheck(Person person)
+ {
+ return p => p.Id == person.Id;
+ }
+
+ [Fact]
+ public async Task GetBrowsePersonDtos()
+ {
+ await ResetDb();
+ await SeedDb();
+
+ // Get people from database for assertions
+ var sharedSeriesChaptersPerson = GetPersonByName("Shared Series Chapter Person");
+ var lib0SeriesPerson = GetPersonByName("Lib0 Series Person");
+ var lib1SeriesPerson = GetPersonByName("Lib1 Series Person");
+ var lib1ChapterAgePerson = GetPersonByName("Lib1 Chapter Age Person");
+ var allPeople = Context.Person.ToList();
+
+ var fullAccessPeople =
+ await UnitOfWork.PersonRepository.GetBrowsePersonDtos(_fullAccess.Id, new BrowsePersonFilterDto(),
+ new UserParams());
+ Assert.Equal(allPeople.Count, fullAccessPeople.TotalCount);
+
+ foreach (var person in allPeople)
+ Assert.Contains(fullAccessPeople, ContainsPersonCheck(person));
+
+ // 1 series in lib0, 2 series in lib1
+ Assert.Equal(3, fullAccessPeople.First(dto => dto.Id == sharedSeriesChaptersPerson.Id).SeriesCount);
+ // 3 series with each 2 chapters
+ Assert.Equal(6, fullAccessPeople.First(dto => dto.Id == sharedSeriesChaptersPerson.Id).ChapterCount);
+ // 1 series in lib0
+ Assert.Equal(1, fullAccessPeople.First(dto => dto.Id == lib0SeriesPerson.Id).SeriesCount);
+ // 2 series in lib1
+ Assert.Equal(2, fullAccessPeople.First(dto => dto.Id == lib1SeriesPerson.Id).SeriesCount);
+
+ var restrictedAccessPeople =
+ await UnitOfWork.PersonRepository.GetBrowsePersonDtos(_restrictedAccess.Id, new BrowsePersonFilterDto(),
+ new UserParams());
+
+ Assert.Equal(7, restrictedAccessPeople.TotalCount);
+
+ Assert.Contains(restrictedAccessPeople, ContainsPersonCheck(GetPersonByName("Shared Series Chapter Person")));
+ Assert.Contains(restrictedAccessPeople, ContainsPersonCheck(GetPersonByName("Shared Series Person")));
+ Assert.Contains(restrictedAccessPeople, ContainsPersonCheck(GetPersonByName("Shared Chapters Person")));
+ Assert.Contains(restrictedAccessPeople, ContainsPersonCheck(GetPersonByName("Lib1 Series Chapter Person")));
+ Assert.Contains(restrictedAccessPeople, ContainsPersonCheck(GetPersonByName("Lib1 Series Person")));
+ Assert.Contains(restrictedAccessPeople, ContainsPersonCheck(GetPersonByName("Lib1 Chapters Person")));
+ Assert.Contains(restrictedAccessPeople, ContainsPersonCheck(GetPersonByName("Lib1 Chapter Age Person")));
+
+ // 2 series in lib1, no series in lib0
+ Assert.Equal(2, restrictedAccessPeople.First(dto => dto.Id == sharedSeriesChaptersPerson.Id).SeriesCount);
+ // 2 series with each 2 chapters
+ Assert.Equal(4, restrictedAccessPeople.First(dto => dto.Id == sharedSeriesChaptersPerson.Id).ChapterCount);
+ // 2 series in lib1
+ Assert.Equal(2, restrictedAccessPeople.First(dto => dto.Id == lib1SeriesPerson.Id).SeriesCount);
+
+ var restrictedAgeAccessPeople = await UnitOfWork.PersonRepository.GetBrowsePersonDtos(_restrictedAgeAccess.Id,
+ new BrowsePersonFilterDto(), new UserParams());
+
+ // Note: There is a potential bug here where a person in a different chapter of an age restricted series will show up
+ Assert.Equal(6, restrictedAgeAccessPeople.TotalCount);
+
+ // No access to the age restricted chapter
+ Assert.DoesNotContain(restrictedAgeAccessPeople, ContainsPersonCheck(lib1ChapterAgePerson));
+ }
+
+ [Fact]
+ public async Task GetRolesForPersonByName()
+ {
+ await ResetDb();
+ await SeedDb();
+
+ var sharedSeriesPerson = GetPersonByName("Shared Series Person");
+ var sharedChaptersPerson = GetPersonByName("Shared Chapters Person");
+ var lib1ChapterAgePerson = GetPersonByName("Lib1 Chapter Age Person");
+
+ var sharedSeriesRoles = await UnitOfWork.PersonRepository.GetRolesForPersonByName(sharedSeriesPerson.Id, _fullAccess.Id);
+ var chapterRoles = await UnitOfWork.PersonRepository.GetRolesForPersonByName(sharedChaptersPerson.Id, _fullAccess.Id);
+ var ageChapterRoles = await UnitOfWork.PersonRepository.GetRolesForPersonByName(lib1ChapterAgePerson.Id, _fullAccess.Id);
+ Assert.Equal(3, sharedSeriesRoles.Count());
+ Assert.Equal(6, chapterRoles.Count());
+ Assert.Single(ageChapterRoles);
+
+ var restrictedRoles = await UnitOfWork.PersonRepository.GetRolesForPersonByName(sharedSeriesPerson.Id, _restrictedAccess.Id);
+ var restrictedChapterRoles = await UnitOfWork.PersonRepository.GetRolesForPersonByName(sharedChaptersPerson.Id, _restrictedAccess.Id);
+ var restrictedAgePersonChapterRoles = await UnitOfWork.PersonRepository.GetRolesForPersonByName(lib1ChapterAgePerson.Id, _restrictedAccess.Id);
+ Assert.Equal(2, restrictedRoles.Count());
+ Assert.Equal(4, restrictedChapterRoles.Count());
+ Assert.Single(restrictedAgePersonChapterRoles);
+
+ var restrictedAgeRoles = await UnitOfWork.PersonRepository.GetRolesForPersonByName(sharedSeriesPerson.Id, _restrictedAgeAccess.Id);
+ var restrictedAgeChapterRoles = await UnitOfWork.PersonRepository.GetRolesForPersonByName(sharedChaptersPerson.Id, _restrictedAgeAccess.Id);
+ var restrictedAgeAgePersonChapterRoles = await UnitOfWork.PersonRepository.GetRolesForPersonByName(lib1ChapterAgePerson.Id, _restrictedAgeAccess.Id);
+ Assert.Single(restrictedAgeRoles);
+ Assert.Equal(2, restrictedAgeChapterRoles.Count());
+ // Note: There is a potential bug here where a person in a different chapter of an age restricted series will show up
+ Assert.Empty(restrictedAgeAgePersonChapterRoles);
+ }
+
+ [Fact]
+ public async Task GetPersonDtoByName()
+ {
+ await ResetDb();
+ await SeedDb();
+
+ var allPeople = Context.Person.ToList();
+
+ foreach (var person in allPeople)
+ {
+ Assert.NotNull(await UnitOfWork.PersonRepository.GetPersonDtoByName(person.Name, _fullAccess.Id));
+ }
+
+ Assert.Null(await UnitOfWork.PersonRepository.GetPersonDtoByName("Lib0 Chapters Person", _restrictedAccess.Id));
+ Assert.NotNull(await UnitOfWork.PersonRepository.GetPersonDtoByName("Shared Series Person", _restrictedAccess.Id));
+ Assert.NotNull(await UnitOfWork.PersonRepository.GetPersonDtoByName("Lib1 Series Person", _restrictedAccess.Id));
+
+ Assert.Null(await UnitOfWork.PersonRepository.GetPersonDtoByName("Lib0 Chapters Person", _restrictedAgeAccess.Id));
+ Assert.NotNull(await UnitOfWork.PersonRepository.GetPersonDtoByName("Lib1 Series Person", _restrictedAgeAccess.Id));
+ // Note: There is a potential bug here where a person in a different chapter of an age restricted series will show up
+ Assert.Null(await UnitOfWork.PersonRepository.GetPersonDtoByName("Lib1 Chapter Age Person", _restrictedAgeAccess.Id));
+ }
+
+ [Fact]
+ public async Task GetSeriesKnownFor()
+ {
+ await ResetDb();
+ await SeedDb();
+
+ var sharedSeriesPerson = GetPersonByName("Shared Series Person");
+ var lib1SeriesPerson = GetPersonByName("Lib1 Series Person");
+
+ var series = await UnitOfWork.PersonRepository.GetSeriesKnownFor(sharedSeriesPerson.Id, _fullAccess.Id);
+ Assert.Equal(3, series.Count());
+
+ series = await UnitOfWork.PersonRepository.GetSeriesKnownFor(sharedSeriesPerson.Id, _restrictedAccess.Id);
+ Assert.Equal(2, series.Count());
+
+ series = await UnitOfWork.PersonRepository.GetSeriesKnownFor(sharedSeriesPerson.Id, _restrictedAgeAccess.Id);
+ Assert.Single(series);
+
+ series = await UnitOfWork.PersonRepository.GetSeriesKnownFor(lib1SeriesPerson.Id, _restrictedAgeAccess.Id);
+ Assert.Single(series);
+ }
+
+ [Fact]
+ public async Task GetChaptersForPersonByRole()
+ {
+ await ResetDb();
+ await SeedDb();
+
+ var sharedChaptersPerson = GetPersonByName("Shared Chapters Person");
+
+ // Lib0
+ var chapters = await UnitOfWork.PersonRepository.GetChaptersForPersonByRole(sharedChaptersPerson.Id, _fullAccess.Id, PersonRole.Colorist);
+ var restrictedChapters = await UnitOfWork.PersonRepository.GetChaptersForPersonByRole(sharedChaptersPerson.Id, _restrictedAccess.Id, PersonRole.Colorist);
+ var restrictedAgeChapters = await UnitOfWork.PersonRepository.GetChaptersForPersonByRole(sharedChaptersPerson.Id, _restrictedAgeAccess.Id, PersonRole.Colorist);
+ Assert.Single(chapters);
+ Assert.Empty(restrictedChapters);
+ Assert.Empty(restrictedAgeChapters);
+
+ // Lib1 - age restricted series
+ chapters = await UnitOfWork.PersonRepository.GetChaptersForPersonByRole(sharedChaptersPerson.Id, _fullAccess.Id, PersonRole.Imprint);
+ restrictedChapters = await UnitOfWork.PersonRepository.GetChaptersForPersonByRole(sharedChaptersPerson.Id, _restrictedAccess.Id, PersonRole.Imprint);
+ restrictedAgeChapters = await UnitOfWork.PersonRepository.GetChaptersForPersonByRole(sharedChaptersPerson.Id, _restrictedAgeAccess.Id, PersonRole.Imprint);
+ Assert.Single(chapters);
+ Assert.Single(restrictedChapters);
+ Assert.Empty(restrictedAgeChapters);
+
+ // Lib1 - not age restricted series
+ chapters = await UnitOfWork.PersonRepository.GetChaptersForPersonByRole(sharedChaptersPerson.Id, _fullAccess.Id, PersonRole.Team);
+ restrictedChapters = await UnitOfWork.PersonRepository.GetChaptersForPersonByRole(sharedChaptersPerson.Id, _restrictedAccess.Id, PersonRole.Team);
+ restrictedAgeChapters = await UnitOfWork.PersonRepository.GetChaptersForPersonByRole(sharedChaptersPerson.Id, _restrictedAgeAccess.Id, PersonRole.Team);
+ Assert.Single(chapters);
+ Assert.Single(restrictedChapters);
+ Assert.Single(restrictedAgeChapters);
+ }
+}
diff --git a/API.Tests/Repository/TagRepositoryTests.cs b/API.Tests/Repository/TagRepositoryTests.cs
new file mode 100644
index 000000000..229082eb6
--- /dev/null
+++ b/API.Tests/Repository/TagRepositoryTests.cs
@@ -0,0 +1,278 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using API.DTOs.Metadata.Browse;
+using API.Entities;
+using API.Entities.Enums;
+using API.Entities.Metadata;
+using API.Helpers;
+using API.Helpers.Builders;
+using Xunit;
+
+namespace API.Tests.Repository;
+
+public class TagRepositoryTests : AbstractDbTest
+{
+ private AppUser _fullAccess;
+ private AppUser _restrictedAccess;
+ private AppUser _restrictedAgeAccess;
+
+ protected override async Task ResetDb()
+ {
+ Context.Tag.RemoveRange(Context.Tag);
+ Context.Library.RemoveRange(Context.Library);
+ await Context.SaveChangesAsync();
+ }
+
+ private TestTagSet CreateTestTags()
+ {
+ return new TestTagSet
+ {
+ SharedSeriesChaptersTag = new TagBuilder("Shared Series Chapter Tag").Build(),
+ SharedSeriesTag = new TagBuilder("Shared Series Tag").Build(),
+ SharedChaptersTag = new TagBuilder("Shared Chapters Tag").Build(),
+ Lib0SeriesChaptersTag = new TagBuilder("Lib0 Series Chapter Tag").Build(),
+ Lib0SeriesTag = new TagBuilder("Lib0 Series Tag").Build(),
+ Lib0ChaptersTag = new TagBuilder("Lib0 Chapters Tag").Build(),
+ Lib1SeriesChaptersTag = new TagBuilder("Lib1 Series Chapter Tag").Build(),
+ Lib1SeriesTag = new TagBuilder("Lib1 Series Tag").Build(),
+ Lib1ChaptersTag = new TagBuilder("Lib1 Chapters Tag").Build(),
+ Lib1ChapterAgeTag = new TagBuilder("Lib1 Chapter Age Tag").Build()
+ };
+ }
+
+ private async Task SeedDbWithTags(TestTagSet tags)
+ {
+ await CreateTestUsers();
+ await AddTagsToContext(tags);
+ await CreateLibrariesWithTags(tags);
+ await AssignLibrariesToUsers();
+ }
+
+ private async Task CreateTestUsers()
+ {
+ _fullAccess = new AppUserBuilder("amelia", "amelia@example.com").Build();
+ _restrictedAccess = new AppUserBuilder("mila", "mila@example.com").Build();
+ _restrictedAgeAccess = new AppUserBuilder("eva", "eva@example.com").Build();
+ _restrictedAgeAccess.AgeRestriction = AgeRating.Teen;
+ _restrictedAgeAccess.AgeRestrictionIncludeUnknowns = true;
+
+ Context.Users.Add(_fullAccess);
+ Context.Users.Add(_restrictedAccess);
+ Context.Users.Add(_restrictedAgeAccess);
+ await Context.SaveChangesAsync();
+ }
+
+ private async Task AddTagsToContext(TestTagSet tags)
+ {
+ var allTags = tags.GetAllTags();
+ Context.Tag.AddRange(allTags);
+ await Context.SaveChangesAsync();
+ }
+
+ private async Task CreateLibrariesWithTags(TestTagSet tags)
+ {
+ var lib0 = new LibraryBuilder("lib0")
+ .WithSeries(new SeriesBuilder("lib0-s0")
+ .WithMetadata(new SeriesMetadata
+ {
+ Tags = [tags.SharedSeriesChaptersTag, tags.SharedSeriesTag, tags.Lib0SeriesChaptersTag, tags.Lib0SeriesTag]
+ })
+ .WithVolume(new VolumeBuilder("1")
+ .WithChapter(new ChapterBuilder("1")
+ .WithTags([tags.SharedSeriesChaptersTag, tags.SharedChaptersTag, tags.Lib0SeriesChaptersTag, tags.Lib0ChaptersTag])
+ .Build())
+ .WithChapter(new ChapterBuilder("2")
+ .WithTags([tags.SharedSeriesChaptersTag, tags.SharedChaptersTag, tags.Lib1SeriesChaptersTag, tags.Lib1ChaptersTag])
+ .Build())
+ .Build())
+ .Build())
+ .Build();
+
+ var lib1 = new LibraryBuilder("lib1")
+ .WithSeries(new SeriesBuilder("lib1-s0")
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithTags([tags.SharedSeriesChaptersTag, tags.SharedSeriesTag, tags.Lib1SeriesChaptersTag, tags.Lib1SeriesTag])
+ .WithAgeRating(AgeRating.Mature17Plus)
+ .Build())
+ .WithVolume(new VolumeBuilder("1")
+ .WithChapter(new ChapterBuilder("1")
+ .WithTags([tags.SharedSeriesChaptersTag, tags.SharedChaptersTag, tags.Lib1SeriesChaptersTag, tags.Lib1ChaptersTag])
+ .Build())
+ .WithChapter(new ChapterBuilder("2")
+ .WithTags([tags.SharedSeriesChaptersTag, tags.SharedChaptersTag, tags.Lib1SeriesChaptersTag, tags.Lib1ChaptersTag, tags.Lib1ChapterAgeTag])
+ .WithAgeRating(AgeRating.Mature17Plus)
+ .Build())
+ .Build())
+ .Build())
+ .WithSeries(new SeriesBuilder("lib1-s1")
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithTags([tags.SharedSeriesChaptersTag, tags.SharedSeriesTag, tags.Lib1SeriesChaptersTag, tags.Lib1SeriesTag])
+ .Build())
+ .WithVolume(new VolumeBuilder("1")
+ .WithChapter(new ChapterBuilder("1")
+ .WithTags([tags.SharedSeriesChaptersTag, tags.SharedChaptersTag, tags.Lib1SeriesChaptersTag, tags.Lib1ChaptersTag])
+ .Build())
+ .WithChapter(new ChapterBuilder("2")
+ .WithTags([tags.SharedSeriesChaptersTag, tags.SharedChaptersTag, tags.Lib1SeriesChaptersTag, tags.Lib1ChaptersTag])
+ .WithAgeRating(AgeRating.Mature17Plus)
+ .Build())
+ .Build())
+ .Build())
+ .Build();
+
+ Context.Library.Add(lib0);
+ Context.Library.Add(lib1);
+ await Context.SaveChangesAsync();
+ }
+
+ private async Task AssignLibrariesToUsers()
+ {
+ var lib0 = Context.Library.First(l => l.Name == "lib0");
+ var lib1 = Context.Library.First(l => l.Name == "lib1");
+
+ _fullAccess.Libraries.Add(lib0);
+ _fullAccess.Libraries.Add(lib1);
+ _restrictedAccess.Libraries.Add(lib1);
+ _restrictedAgeAccess.Libraries.Add(lib1);
+
+ await Context.SaveChangesAsync();
+ }
+
+ private static Predicate ContainsTagCheck(Tag tag)
+ {
+ return t => t.Id == tag.Id;
+ }
+
+ private static void AssertTagPresent(IEnumerable tags, Tag expectedTag)
+ {
+ Assert.Contains(tags, ContainsTagCheck(expectedTag));
+ }
+
+ private static void AssertTagNotPresent(IEnumerable tags, Tag expectedTag)
+ {
+ Assert.DoesNotContain(tags, ContainsTagCheck(expectedTag));
+ }
+
+ private static BrowseTagDto GetTagDto(IEnumerable tags, Tag tag)
+ {
+ return tags.First(dto => dto.Id == tag.Id);
+ }
+
+ [Fact]
+ public async Task GetBrowseableTag_FullAccess_ReturnsAllTagsWithCorrectCounts()
+ {
+ // Arrange
+ await ResetDb();
+ var tags = CreateTestTags();
+ await SeedDbWithTags(tags);
+
+ // Act
+ var fullAccessTags = await UnitOfWork.TagRepository.GetBrowseableTag(_fullAccess.Id, new UserParams());
+
+ // Assert
+ Assert.Equal(tags.GetAllTags().Count, fullAccessTags.TotalCount);
+
+ foreach (var tag in tags.GetAllTags())
+ {
+ AssertTagPresent(fullAccessTags, tag);
+ }
+
+ // Verify counts - 1 series lib0, 2 series lib1 = 3 total series
+ Assert.Equal(3, GetTagDto(fullAccessTags, tags.SharedSeriesChaptersTag).SeriesCount);
+ Assert.Equal(6, GetTagDto(fullAccessTags, tags.SharedSeriesChaptersTag).ChapterCount);
+ Assert.Equal(1, GetTagDto(fullAccessTags, tags.Lib0SeriesTag).SeriesCount);
+ }
+
+ [Fact]
+ public async Task GetBrowseableTag_RestrictedAccess_ReturnsOnlyAccessibleTags()
+ {
+ // Arrange
+ await ResetDb();
+ var tags = CreateTestTags();
+ await SeedDbWithTags(tags);
+
+ // Act
+ var restrictedAccessTags = await UnitOfWork.TagRepository.GetBrowseableTag(_restrictedAccess.Id, new UserParams());
+
+ // Assert - Should see: 3 shared + 4 library 1 specific = 7 tags
+ Assert.Equal(7, restrictedAccessTags.TotalCount);
+
+ // Verify shared and Library 1 tags are present
+ AssertTagPresent(restrictedAccessTags, tags.SharedSeriesChaptersTag);
+ AssertTagPresent(restrictedAccessTags, tags.SharedSeriesTag);
+ AssertTagPresent(restrictedAccessTags, tags.SharedChaptersTag);
+ AssertTagPresent(restrictedAccessTags, tags.Lib1SeriesChaptersTag);
+ AssertTagPresent(restrictedAccessTags, tags.Lib1SeriesTag);
+ AssertTagPresent(restrictedAccessTags, tags.Lib1ChaptersTag);
+ AssertTagPresent(restrictedAccessTags, tags.Lib1ChapterAgeTag);
+
+ // Verify Library 0 specific tags are not present
+ AssertTagNotPresent(restrictedAccessTags, tags.Lib0SeriesChaptersTag);
+ AssertTagNotPresent(restrictedAccessTags, tags.Lib0SeriesTag);
+ AssertTagNotPresent(restrictedAccessTags, tags.Lib0ChaptersTag);
+
+ // Verify counts - 2 series lib1
+ Assert.Equal(2, GetTagDto(restrictedAccessTags, tags.SharedSeriesChaptersTag).SeriesCount);
+ Assert.Equal(4, GetTagDto(restrictedAccessTags, tags.SharedSeriesChaptersTag).ChapterCount);
+ Assert.Equal(2, GetTagDto(restrictedAccessTags, tags.Lib1SeriesTag).SeriesCount);
+ Assert.Equal(4, GetTagDto(restrictedAccessTags, tags.Lib1ChaptersTag).ChapterCount);
+ }
+
+ [Fact]
+ public async Task GetBrowseableTag_RestrictedAgeAccess_FiltersAgeRestrictedContent()
+ {
+ // Arrange
+ await ResetDb();
+ var tags = CreateTestTags();
+ await SeedDbWithTags(tags);
+
+ // Act
+ var restrictedAgeAccessTags = await UnitOfWork.TagRepository.GetBrowseableTag(_restrictedAgeAccess.Id, new UserParams());
+
+ // Assert - Should see: 3 shared + 3 lib1 specific = 6 tags (age-restricted tag filtered out)
+ Assert.Equal(6, restrictedAgeAccessTags.TotalCount);
+
+ // Verify accessible tags are present
+ AssertTagPresent(restrictedAgeAccessTags, tags.SharedSeriesChaptersTag);
+ AssertTagPresent(restrictedAgeAccessTags, tags.SharedSeriesTag);
+ AssertTagPresent(restrictedAgeAccessTags, tags.SharedChaptersTag);
+ AssertTagPresent(restrictedAgeAccessTags, tags.Lib1SeriesChaptersTag);
+ AssertTagPresent(restrictedAgeAccessTags, tags.Lib1SeriesTag);
+ AssertTagPresent(restrictedAgeAccessTags, tags.Lib1ChaptersTag);
+
+ // Verify age-restricted tag is filtered out
+ AssertTagNotPresent(restrictedAgeAccessTags, tags.Lib1ChapterAgeTag);
+
+ // Verify counts - 1 series lib1 (age-restricted series filtered out)
+ Assert.Equal(1, GetTagDto(restrictedAgeAccessTags, tags.SharedSeriesChaptersTag).SeriesCount);
+ Assert.Equal(2, GetTagDto(restrictedAgeAccessTags, tags.SharedSeriesChaptersTag).ChapterCount);
+ Assert.Equal(1, GetTagDto(restrictedAgeAccessTags, tags.Lib1SeriesTag).SeriesCount);
+ Assert.Equal(2, GetTagDto(restrictedAgeAccessTags, tags.Lib1ChaptersTag).ChapterCount);
+ }
+
+ private class TestTagSet
+ {
+ public Tag SharedSeriesChaptersTag { get; set; }
+ public Tag SharedSeriesTag { get; set; }
+ public Tag SharedChaptersTag { get; set; }
+ public Tag Lib0SeriesChaptersTag { get; set; }
+ public Tag Lib0SeriesTag { get; set; }
+ public Tag Lib0ChaptersTag { get; set; }
+ public Tag Lib1SeriesChaptersTag { get; set; }
+ public Tag Lib1SeriesTag { get; set; }
+ public Tag Lib1ChaptersTag { get; set; }
+ public Tag Lib1ChapterAgeTag { get; set; }
+
+ public List GetAllTags()
+ {
+ return
+ [
+ SharedSeriesChaptersTag, SharedSeriesTag, SharedChaptersTag,
+ Lib0SeriesChaptersTag, Lib0SeriesTag, Lib0ChaptersTag,
+ Lib1SeriesChaptersTag, Lib1SeriesTag, Lib1ChaptersTag, Lib1ChapterAgeTag
+ ];
+ }
+ }
+}
diff --git a/API.Tests/Services/BookServiceTests.cs b/API.Tests/Services/BookServiceTests.cs
index a80c1ca01..5848c74ba 100644
--- a/API.Tests/Services/BookServiceTests.cs
+++ b/API.Tests/Services/BookServiceTests.cs
@@ -137,7 +137,7 @@ public class BookServiceTests
var comicInfo = _bookService.GetComicInfo(filePath);
Assert.NotNull(comicInfo);
- var parserInfo = pdfParser.Parse(filePath, testDirectory, ds.GetParentDirectoryName(testDirectory), LibraryType.Book, comicInfo);
+ var parserInfo = pdfParser.Parse(filePath, testDirectory, ds.GetParentDirectoryName(testDirectory), LibraryType.Book, true, comicInfo);
Assert.NotNull(parserInfo);
Assert.Equal(parserInfo.Title, comicInfo.Title);
Assert.Equal(parserInfo.Series, comicInfo.Title);
diff --git a/API.Tests/Services/CacheServiceTests.cs b/API.Tests/Services/CacheServiceTests.cs
index 5c1752cd8..caf1ae393 100644
--- a/API.Tests/Services/CacheServiceTests.cs
+++ b/API.Tests/Services/CacheServiceTests.cs
@@ -50,12 +50,12 @@ internal class MockReadingItemServiceForCacheService : IReadingItemService
throw new System.NotImplementedException();
}
- public ParserInfo Parse(string path, string rootPath, string libraryRoot, LibraryType type)
+ public ParserInfo Parse(string path, string rootPath, string libraryRoot, LibraryType type, bool enableMetadata = true)
{
throw new System.NotImplementedException();
}
- public ParserInfo ParseFile(string path, string rootPath, string libraryRoot, LibraryType type)
+ public ParserInfo ParseFile(string path, string rootPath, string libraryRoot, LibraryType type, bool enableMetadata = true)
{
throw new System.NotImplementedException();
}
diff --git a/API.Tests/Services/ExternalMetadataServiceTests.cs b/API.Tests/Services/ExternalMetadataServiceTests.cs
index c2c226538..973b7c6df 100644
--- a/API.Tests/Services/ExternalMetadataServiceTests.cs
+++ b/API.Tests/Services/ExternalMetadataServiceTests.cs
@@ -15,6 +15,7 @@ using API.Entities.Person;
using API.Helpers.Builders;
using API.Services.Plus;
using API.Services.Tasks.Metadata;
+using API.Services.Tasks.Scanner.Parser;
using API.SignalR;
using Hangfire;
using Microsoft.EntityFrameworkCore;
@@ -42,7 +43,7 @@ public class ExternalMetadataServiceTests : AbstractDbTest
_externalMetadataService = new ExternalMetadataService(UnitOfWork, Substitute.For>(),
Mapper, Substitute.For(), Substitute.For(), Substitute.For(),
- Substitute.For());
+ Substitute.For(), Substitute.For());
}
#region Gloabl
@@ -881,6 +882,217 @@ public class ExternalMetadataServiceTests : AbstractDbTest
}
+ [Fact]
+ public void IsSeriesCompleted_ExactMatch()
+ {
+ const string seriesName = "Test - Exact Match";
+ var series = new SeriesBuilder(seriesName)
+ .WithLibraryId(1)
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithMaxCount(5)
+ .WithTotalCount(5)
+ .Build())
+ .Build();
+
+ var chapters = new List();
+ var externalMetadata = new ExternalSeriesDetailDto { Chapters = 5, Volumes = 0 };
+
+ var result = ExternalMetadataService.IsSeriesCompleted(series, chapters, externalMetadata, Parser.DefaultChapterNumber);
+
+ Assert.True(result);
+ }
+
+ [Fact]
+ public void IsSeriesCompleted_Volumes_DecimalVolumes()
+ {
+ const string seriesName = "Test - Volume Complete";
+ var series = new SeriesBuilder(seriesName)
+ .WithLibraryId(1)
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithMaxCount(2)
+ .WithTotalCount(3)
+ .Build())
+ .WithVolume(new VolumeBuilder("1").WithNumber(1).Build())
+ .WithVolume(new VolumeBuilder("2").WithNumber(2).Build())
+ .WithVolume(new VolumeBuilder("2.5").WithNumber(2.5f).Build())
+ .Build();
+
+ var chapters = new List();
+ // External metadata includes decimal volume 2.5
+ var externalMetadata = new ExternalSeriesDetailDto { Chapters = 0, Volumes = 3 };
+
+ var result = ExternalMetadataService.IsSeriesCompleted(series, chapters, externalMetadata, 2);
+
+ Assert.True(result);
+ Assert.Equal(3, series.Metadata.MaxCount);
+ Assert.Equal(3, series.Metadata.TotalCount);
+ }
+
+ ///
+ /// This is validating that we get a completed even though we have a special chapter and AL doesn't count it
+ ///
+ [Fact]
+ public void IsSeriesCompleted_Volumes_HasSpecialAndDecimal_ExternalNoSpecial()
+ {
+ const string seriesName = "Test - Volume Complete";
+ var series = new SeriesBuilder(seriesName)
+ .WithLibraryId(1)
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithMaxCount(2)
+ .WithTotalCount(3)
+ .Build())
+ .WithVolume(new VolumeBuilder("1").WithNumber(1).Build())
+ .WithVolume(new VolumeBuilder("1.5").WithNumber(1.5f).Build())
+ .WithVolume(new VolumeBuilder("2").WithNumber(2).Build())
+ .WithVolume(new VolumeBuilder(Parser.SpecialVolume).Build())
+ .Build();
+
+ var chapters = new List();
+ // External metadata includes volume 1.5, but not the special
+ var externalMetadata = new ExternalSeriesDetailDto { Chapters = 0, Volumes = 3 };
+
+ var result = ExternalMetadataService.IsSeriesCompleted(series, chapters, externalMetadata, 2);
+
+ Assert.True(result);
+ Assert.Equal(3, series.Metadata.MaxCount);
+ Assert.Equal(3, series.Metadata.TotalCount);
+ }
+
+ ///
+ /// This unit test also illustrates the bug where you may get a false positive if you had Volumes 1,2, and 2.1. While
+ /// missing volume 3. With the external metadata expecting non-decimal volumes.
+ /// i.e. it would fail if we only had one decimal volume
+ ///
+ [Fact]
+ public void IsSeriesCompleted_Volumes_TooManyDecimalVolumes()
+ {
+ const string seriesName = "Test - Volume Complete";
+ var series = new SeriesBuilder(seriesName)
+ .WithLibraryId(1)
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithMaxCount(2)
+ .WithTotalCount(3)
+ .Build())
+ .WithVolume(new VolumeBuilder("1").WithNumber(1).Build())
+ .WithVolume(new VolumeBuilder("2").WithNumber(2).Build())
+ .WithVolume(new VolumeBuilder("2.1").WithNumber(2.1f).Build())
+ .WithVolume(new VolumeBuilder("2.2").WithNumber(2.2f).Build())
+ .Build();
+
+ var chapters = new List();
+ // External metadata includes no special or decimals. There are 3 volumes. And we're missing volume 3
+ var externalMetadata = new ExternalSeriesDetailDto { Chapters = 0, Volumes = 3 };
+
+ var result = ExternalMetadataService.IsSeriesCompleted(series, chapters, externalMetadata, 2);
+
+ Assert.False(result);
+ }
+
+ [Fact]
+ public void IsSeriesCompleted_NoVolumes_GEQChapterCheck()
+ {
+ // We own 11 chapters, the external metadata expects 10
+ const string seriesName = "Test - Chapter MaxCount, no volumes";
+ var series = new SeriesBuilder(seriesName)
+ .WithLibraryId(1)
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithMaxCount(11)
+ .WithTotalCount(10)
+ .Build())
+ .Build();
+
+ var chapters = new List();
+ var externalMetadata = new ExternalSeriesDetailDto { Chapters = 10, Volumes = 0 };
+
+ var result = ExternalMetadataService.IsSeriesCompleted(series, chapters, externalMetadata, Parser.DefaultChapterNumber);
+
+ Assert.True(result);
+ Assert.Equal(11, series.Metadata.TotalCount);
+ Assert.Equal(11, series.Metadata.MaxCount);
+ }
+
+ [Fact]
+ public void IsSeriesCompleted_NoVolumes_IncludeAllChaptersCheck()
+ {
+ const string seriesName = "Test - Chapter Count";
+ var series = new SeriesBuilder(seriesName)
+ .WithLibraryId(1)
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithMaxCount(7)
+ .WithTotalCount(10)
+ .Build())
+ .Build();
+
+ var chapters = new List
+ {
+ new ChapterBuilder("0").Build(),
+ new ChapterBuilder("2").Build(),
+ new ChapterBuilder("3").Build(),
+ new ChapterBuilder("4").Build(),
+ new ChapterBuilder("5").Build(),
+ new ChapterBuilder("6").Build(),
+ new ChapterBuilder("7").Build(),
+ new ChapterBuilder("7.1").Build(),
+ new ChapterBuilder("7.2").Build(),
+ new ChapterBuilder("7.3").Build()
+ };
+ // External metadata includes prologues (0) and extra's (7.X)
+ var externalMetadata = new ExternalSeriesDetailDto { Chapters = 10, Volumes = 0 };
+
+ var result = ExternalMetadataService.IsSeriesCompleted(series, chapters, externalMetadata, Parser.DefaultChapterNumber);
+
+ Assert.True(result);
+ Assert.Equal(10, series.Metadata.TotalCount);
+ Assert.Equal(10, series.Metadata.MaxCount);
+ }
+
+ [Fact]
+ public void IsSeriesCompleted_NotEnoughVolumes()
+ {
+ const string seriesName = "Test - Incomplete Volume";
+ var series = new SeriesBuilder(seriesName)
+ .WithLibraryId(1)
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithMaxCount(2)
+ .WithTotalCount(5)
+ .Build())
+ .WithVolume(new VolumeBuilder("1").WithNumber(1).Build())
+ .WithVolume(new VolumeBuilder("2").WithNumber(2).Build())
+ .Build();
+
+ var chapters = new List();
+ var externalMetadata = new ExternalSeriesDetailDto { Chapters = 0, Volumes = 5 };
+
+ var result = ExternalMetadataService.IsSeriesCompleted(series, chapters, externalMetadata, 2);
+
+ Assert.False(result);
+ }
+
+ [Fact]
+ public void IsSeriesCompleted_NoVolumes_NotEnoughChapters()
+ {
+ const string seriesName = "Test - Incomplete Chapter";
+ var series = new SeriesBuilder(seriesName)
+ .WithLibraryId(1)
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithMaxCount(5)
+ .WithTotalCount(8)
+ .Build())
+ .Build();
+
+ var chapters = new List
+ {
+ new ChapterBuilder("1").Build(),
+ new ChapterBuilder("2").Build(),
+ new ChapterBuilder("3").Build()
+ };
+ var externalMetadata = new ExternalSeriesDetailDto { Chapters = 10, Volumes = 0 };
+
+ var result = ExternalMetadataService.IsSeriesCompleted(series, chapters, externalMetadata, Parser.DefaultChapterNumber);
+
+ Assert.False(result);
+ }
+
#endregion
@@ -1678,6 +1890,130 @@ public class ExternalMetadataServiceTests : AbstractDbTest
#endregion
+ #region People Alias
+
+ [Fact]
+ public async Task PeopleAliasing_AddAsAlias()
+ {
+ await ResetDb();
+
+ const string seriesName = "Test - People - Add as Alias";
+ var series = new SeriesBuilder(seriesName)
+ .WithLibraryId(1)
+ .WithMetadata(new SeriesMetadataBuilder()
+ .Build())
+ .Build();
+ Context.Series.Attach(series);
+ Context.Person.Add(new PersonBuilder("John Doe").Build());
+ await Context.SaveChangesAsync();
+
+ var metadataSettings = await UnitOfWork.SettingsRepository.GetMetadataSettings();
+ metadataSettings.Enabled = true;
+ metadataSettings.EnablePeople = true;
+ metadataSettings.FirstLastPeopleNaming = true;
+ metadataSettings.Overrides = [MetadataSettingField.People];
+ metadataSettings.PersonRoles = [PersonRole.Writer];
+ Context.MetadataSettings.Update(metadataSettings);
+ await Context.SaveChangesAsync();
+
+ await _externalMetadataService.WriteExternalMetadataToSeries(new ExternalSeriesDetailDto()
+ {
+ Name = seriesName,
+ Staff = [CreateStaff("Doe", "John", "Story")]
+ }, 1);
+
+ var postSeries = await UnitOfWork.SeriesRepository.GetSeriesByIdAsync(1, SeriesIncludes.Metadata);
+ Assert.NotNull(postSeries);
+
+ var allWriters = postSeries.Metadata.People.Where(p => p.Role == PersonRole.Writer).ToList();
+ Assert.Single(allWriters);
+
+ var johnDoe = allWriters[0].Person;
+
+ Assert.Contains("Doe John", johnDoe.Aliases.Select(pa => pa.Alias));
+ }
+
+ [Fact]
+ public async Task PeopleAliasing_AddOnAlias()
+ {
+ await ResetDb();
+
+ const string seriesName = "Test - People - Add as Alias";
+ var series = new SeriesBuilder(seriesName)
+ .WithLibraryId(1)
+ .WithMetadata(new SeriesMetadataBuilder()
+ .Build())
+ .Build();
+ Context.Series.Attach(series);
+
+ Context.Person.Add(new PersonBuilder("John Doe").WithAlias("Doe John").Build());
+
+ await Context.SaveChangesAsync();
+
+ var metadataSettings = await UnitOfWork.SettingsRepository.GetMetadataSettings();
+ metadataSettings.Enabled = true;
+ metadataSettings.EnablePeople = true;
+ metadataSettings.FirstLastPeopleNaming = true;
+ metadataSettings.Overrides = [MetadataSettingField.People];
+ metadataSettings.PersonRoles = [PersonRole.Writer];
+ Context.MetadataSettings.Update(metadataSettings);
+ await Context.SaveChangesAsync();
+
+ await _externalMetadataService.WriteExternalMetadataToSeries(new ExternalSeriesDetailDto()
+ {
+ Name = seriesName,
+ Staff = [CreateStaff("Doe", "John", "Story")]
+ }, 1);
+
+ var postSeries = await UnitOfWork.SeriesRepository.GetSeriesByIdAsync(1, SeriesIncludes.Metadata);
+ Assert.NotNull(postSeries);
+
+ var allWriters = postSeries.Metadata.People.Where(p => p.Role == PersonRole.Writer).ToList();
+ Assert.Single(allWriters);
+
+ var johnDoe = allWriters[0].Person;
+
+ Assert.Contains("Doe John", johnDoe.Aliases.Select(pa => pa.Alias));
+ }
+
+ [Fact]
+ public async Task PeopleAliasing_DontAddAsAlias_SameButNotSwitched()
+ {
+ await ResetDb();
+
+ const string seriesName = "Test - People - Add as Alias";
+ var series = new SeriesBuilder(seriesName)
+ .WithLibraryId(1)
+ .WithMetadata(new SeriesMetadataBuilder()
+ .Build())
+ .Build();
+ Context.Series.Attach(series);
+ await Context.SaveChangesAsync();
+
+ var metadataSettings = await UnitOfWork.SettingsRepository.GetMetadataSettings();
+ metadataSettings.Enabled = true;
+ metadataSettings.EnablePeople = true;
+ metadataSettings.FirstLastPeopleNaming = true;
+ metadataSettings.Overrides = [MetadataSettingField.People];
+ metadataSettings.PersonRoles = [PersonRole.Writer];
+ Context.MetadataSettings.Update(metadataSettings);
+ await Context.SaveChangesAsync();
+
+ await _externalMetadataService.WriteExternalMetadataToSeries(new ExternalSeriesDetailDto()
+ {
+ Name = seriesName,
+ Staff = [CreateStaff("John", "Doe Doe", "Story"), CreateStaff("Doe", "John Doe", "Story")]
+ }, 1);
+
+ var postSeries = await UnitOfWork.SeriesRepository.GetSeriesByIdAsync(1, SeriesIncludes.Metadata);
+ Assert.NotNull(postSeries);
+
+ var allWriters = postSeries.Metadata.People.Where(p => p.Role == PersonRole.Writer).ToList();
+ Assert.Equal(2, allWriters.Count);
+ }
+
+ #endregion
+
#region People - Characters
[Fact]
@@ -2811,6 +3147,8 @@ public class ExternalMetadataServiceTests : AbstractDbTest
metadataSettings.EnableTags = false;
metadataSettings.EnablePublicationStatus = false;
metadataSettings.EnableStartDate = false;
+ metadataSettings.FieldMappings = [];
+ metadataSettings.AgeRatingMappings = new Dictionary();
Context.MetadataSettings.Update(metadataSettings);
await Context.SaveChangesAsync();
diff --git a/API.Tests/Services/ImageServiceTests.cs b/API.Tests/Services/ImageServiceTests.cs
index a1073a55b..f2c87e1ad 100644
--- a/API.Tests/Services/ImageServiceTests.cs
+++ b/API.Tests/Services/ImageServiceTests.cs
@@ -161,10 +161,10 @@ public class ImageServiceTests
private static void GenerateColorImage(string hexColor, string outputPath)
{
- var color = ImageService.HexToRgb(hexColor);
- using var colorImage = Image.Black(200, 100);
- using var output = colorImage + new[] { color.R / 255.0, color.G / 255.0, color.B / 255.0 };
- output.WriteToFile(outputPath);
+ var (r, g, b) = ImageService.HexToRgb(hexColor);
+ using var blackImage = Image.Black(200, 100);
+ using var colorImage = blackImage.NewFromImage(r, g, b);
+ colorImage.WriteToFile(outputPath);
}
private void GenerateHtmlFileForColorScape()
diff --git a/API.Tests/Services/ParseScannedFilesTests.cs b/API.Tests/Services/ParseScannedFilesTests.cs
index f8714f69a..a732b2526 100644
--- a/API.Tests/Services/ParseScannedFilesTests.cs
+++ b/API.Tests/Services/ParseScannedFilesTests.cs
@@ -58,35 +58,35 @@ public class MockReadingItemService : IReadingItemService
throw new NotImplementedException();
}
- public ParserInfo Parse(string path, string rootPath, string libraryRoot, LibraryType type)
+ public ParserInfo Parse(string path, string rootPath, string libraryRoot, LibraryType type, bool enableMetadata)
{
if (_comicVineParser.IsApplicable(path, type))
{
- return _comicVineParser.Parse(path, rootPath, libraryRoot, type, GetComicInfo(path));
+ return _comicVineParser.Parse(path, rootPath, libraryRoot, type, enableMetadata, GetComicInfo(path));
}
if (_imageParser.IsApplicable(path, type))
{
- return _imageParser.Parse(path, rootPath, libraryRoot, type, GetComicInfo(path));
+ return _imageParser.Parse(path, rootPath, libraryRoot, type, enableMetadata, GetComicInfo(path));
}
if (_bookParser.IsApplicable(path, type))
{
- return _bookParser.Parse(path, rootPath, libraryRoot, type, GetComicInfo(path));
+ return _bookParser.Parse(path, rootPath, libraryRoot, type, enableMetadata, GetComicInfo(path));
}
if (_pdfParser.IsApplicable(path, type))
{
- return _pdfParser.Parse(path, rootPath, libraryRoot, type, GetComicInfo(path));
+ return _pdfParser.Parse(path, rootPath, libraryRoot, type, enableMetadata, GetComicInfo(path));
}
if (_basicParser.IsApplicable(path, type))
{
- return _basicParser.Parse(path, rootPath, libraryRoot, type, GetComicInfo(path));
+ return _basicParser.Parse(path, rootPath, libraryRoot, type, enableMetadata, GetComicInfo(path));
}
return null;
}
- public ParserInfo ParseFile(string path, string rootPath, string libraryRoot, LibraryType type)
+ public ParserInfo ParseFile(string path, string rootPath, string libraryRoot, LibraryType type, bool enableMetadata)
{
- return Parse(path, rootPath, libraryRoot, type);
+ return Parse(path, rootPath, libraryRoot, type, enableMetadata);
}
}
diff --git a/API.Tests/Services/PersonServiceTests.cs b/API.Tests/Services/PersonServiceTests.cs
new file mode 100644
index 000000000..5c1929b1c
--- /dev/null
+++ b/API.Tests/Services/PersonServiceTests.cs
@@ -0,0 +1,286 @@
+using System.Linq;
+using System.Threading.Tasks;
+using API.Data.Repositories;
+using API.Entities;
+using API.Entities.Enums;
+using API.Entities.Person;
+using API.Extensions;
+using API.Helpers.Builders;
+using API.Services;
+using Xunit;
+
+namespace API.Tests.Services;
+
+public class PersonServiceTests: AbstractDbTest
+{
+
+ [Fact]
+ public async Task PersonMerge_KeepNonEmptyMetadata()
+ {
+ var ps = new PersonService(UnitOfWork);
+
+ var person1 = new Person
+ {
+ Name = "Casey Delores",
+ NormalizedName = "Casey Delores".ToNormalized(),
+ HardcoverId = "ANonEmptyId",
+ MalId = 12,
+ };
+
+ var person2 = new Person
+ {
+ Name= "Delores Casey",
+ NormalizedName = "Delores Casey".ToNormalized(),
+ Description = "Hi, I'm Delores Casey!",
+ Aliases = [new PersonAliasBuilder("Casey, Delores").Build()],
+ AniListId = 27,
+ };
+
+ UnitOfWork.PersonRepository.Attach(person1);
+ UnitOfWork.PersonRepository.Attach(person2);
+ await UnitOfWork.CommitAsync();
+
+ await ps.MergePeopleAsync(person2, person1);
+
+ var allPeople = await UnitOfWork.PersonRepository.GetAllPeople();
+ Assert.Single(allPeople);
+
+ var person = allPeople[0];
+ Assert.Equal("Casey Delores", person.Name);
+ Assert.NotEmpty(person.Description);
+ Assert.Equal(27, person.AniListId);
+ Assert.NotNull(person.HardcoverId);
+ Assert.NotEmpty(person.HardcoverId);
+ Assert.Contains(person.Aliases, pa => pa.Alias == "Delores Casey");
+ Assert.Contains(person.Aliases, pa => pa.Alias == "Casey, Delores");
+ }
+
+ [Fact]
+ public async Task PersonMerge_MergedPersonDestruction()
+ {
+ var ps = new PersonService(UnitOfWork);
+
+ var person1 = new Person
+ {
+ Name = "Casey Delores",
+ NormalizedName = "Casey Delores".ToNormalized(),
+ };
+
+ var person2 = new Person
+ {
+ Name = "Delores Casey",
+ NormalizedName = "Delores Casey".ToNormalized(),
+ };
+
+ UnitOfWork.PersonRepository.Attach(person1);
+ UnitOfWork.PersonRepository.Attach(person2);
+ await UnitOfWork.CommitAsync();
+
+ await ps.MergePeopleAsync(person2, person1);
+ var allPeople = await UnitOfWork.PersonRepository.GetAllPeople();
+ Assert.Single(allPeople);
+ }
+
+ [Fact]
+ public async Task PersonMerge_RetentionChapters()
+ {
+ var ps = new PersonService(UnitOfWork);
+
+ var library = new LibraryBuilder("My Library").Build();
+ UnitOfWork.LibraryRepository.Add(library);
+ await UnitOfWork.CommitAsync();
+
+ var user = new AppUserBuilder("Amelia", "amelia@localhost")
+ .WithLibrary(library).Build();
+ UnitOfWork.UserRepository.Add(user);
+
+ var person = new PersonBuilder("Jillian Cowan").Build();
+
+ var person2 = new PersonBuilder("Cowan Jillian").Build();
+
+ var chapter = new ChapterBuilder("1")
+ .WithPerson(person, PersonRole.Editor)
+ .Build();
+
+ var chapter2 = new ChapterBuilder("2")
+ .WithPerson(person2, PersonRole.Editor)
+ .Build();
+
+ var series = new SeriesBuilder("Test 1")
+ .WithLibraryId(library.Id)
+ .WithVolume(new VolumeBuilder("1")
+ .WithChapter(chapter)
+ .Build())
+ .Build();
+
+ var series2 = new SeriesBuilder("Test 2")
+ .WithLibraryId(library.Id)
+ .WithVolume(new VolumeBuilder("2")
+ .WithChapter(chapter2)
+ .Build())
+ .Build();
+
+ UnitOfWork.SeriesRepository.Add(series);
+ UnitOfWork.SeriesRepository.Add(series2);
+ await UnitOfWork.CommitAsync();
+
+ await ps.MergePeopleAsync(person2, person);
+
+ var allPeople = await UnitOfWork.PersonRepository.GetAllPeople();
+ Assert.Single(allPeople);
+ var mergedPerson = allPeople[0];
+
+ Assert.Equal("Jillian Cowan", mergedPerson.Name);
+
+ var chapters = await UnitOfWork.PersonRepository.GetChaptersForPersonByRole(1, 1, PersonRole.Editor);
+ Assert.Equal(2, chapters.Count());
+
+ chapter = await UnitOfWork.ChapterRepository.GetChapterAsync(1, ChapterIncludes.People);
+ Assert.NotNull(chapter);
+ Assert.Single(chapter.People);
+
+ chapter2 = await UnitOfWork.ChapterRepository.GetChapterAsync(2, ChapterIncludes.People);
+ Assert.NotNull(chapter2);
+ Assert.Single(chapter2.People);
+
+ Assert.Equal(chapter.People.First().PersonId, chapter2.People.First().PersonId);
+ }
+
+ [Fact]
+ public async Task PersonMerge_NoDuplicateChaptersOrSeries()
+ {
+ await ResetDb();
+
+ var ps = new PersonService(UnitOfWork);
+
+ var library = new LibraryBuilder("My Library").Build();
+ UnitOfWork.LibraryRepository.Add(library);
+ await UnitOfWork.CommitAsync();
+
+ var user = new AppUserBuilder("Amelia", "amelia@localhost")
+ .WithLibrary(library).Build();
+ UnitOfWork.UserRepository.Add(user);
+
+ var person = new PersonBuilder("Jillian Cowan").Build();
+
+ var person2 = new PersonBuilder("Cowan Jillian").Build();
+
+ var chapter = new ChapterBuilder("1")
+ .WithPerson(person, PersonRole.Editor)
+ .WithPerson(person2, PersonRole.Colorist)
+ .Build();
+
+ var chapter2 = new ChapterBuilder("2")
+ .WithPerson(person2, PersonRole.Editor)
+ .WithPerson(person, PersonRole.Editor)
+ .Build();
+
+ var series = new SeriesBuilder("Test 1")
+ .WithLibraryId(library.Id)
+ .WithVolume(new VolumeBuilder("1")
+ .WithChapter(chapter)
+ .Build())
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithPerson(person, PersonRole.Editor)
+ .WithPerson(person2, PersonRole.Editor)
+ .Build())
+ .Build();
+
+ var series2 = new SeriesBuilder("Test 2")
+ .WithLibraryId(library.Id)
+ .WithVolume(new VolumeBuilder("2")
+ .WithChapter(chapter2)
+ .Build())
+ .WithMetadata(new SeriesMetadataBuilder()
+ .WithPerson(person, PersonRole.Editor)
+ .WithPerson(person2, PersonRole.Colorist)
+ .Build())
+ .Build();
+
+ UnitOfWork.SeriesRepository.Add(series);
+ UnitOfWork.SeriesRepository.Add(series2);
+ await UnitOfWork.CommitAsync();
+
+ await ps.MergePeopleAsync(person2, person);
+ var allPeople = await UnitOfWork.PersonRepository.GetAllPeople();
+ Assert.Single(allPeople);
+
+ var mergedPerson = await UnitOfWork.PersonRepository.GetPersonById(person.Id, PersonIncludes.All);
+ Assert.NotNull(mergedPerson);
+ Assert.Equal(3, mergedPerson.ChapterPeople.Count);
+ Assert.Equal(3, mergedPerson.SeriesMetadataPeople.Count);
+
+ chapter = await UnitOfWork.ChapterRepository.GetChapterAsync(chapter.Id, ChapterIncludes.People);
+ Assert.NotNull(chapter);
+ Assert.Equal(2, chapter.People.Count);
+ Assert.Single(chapter.People.Select(p => p.Person.Id).Distinct());
+ Assert.Contains(chapter.People, p => p.Role == PersonRole.Editor);
+ Assert.Contains(chapter.People, p => p.Role == PersonRole.Colorist);
+
+ chapter2 = await UnitOfWork.ChapterRepository.GetChapterAsync(chapter2.Id, ChapterIncludes.People);
+ Assert.NotNull(chapter2);
+ Assert.Single(chapter2.People);
+ Assert.Contains(chapter2.People, p => p.Role == PersonRole.Editor);
+ Assert.DoesNotContain(chapter2.People, p => p.Role == PersonRole.Colorist);
+
+ series = await UnitOfWork.SeriesRepository.GetSeriesByIdAsync(series.Id, SeriesIncludes.Metadata);
+ Assert.NotNull(series);
+ Assert.Single(series.Metadata.People);
+ Assert.Contains(series.Metadata.People, p => p.Role == PersonRole.Editor);
+ Assert.DoesNotContain(series.Metadata.People, p => p.Role == PersonRole.Colorist);
+
+ series2 = await UnitOfWork.SeriesRepository.GetSeriesByIdAsync(series2.Id, SeriesIncludes.Metadata);
+ Assert.NotNull(series2);
+ Assert.Equal(2, series2.Metadata.People.Count);
+ Assert.Contains(series2.Metadata.People, p => p.Role == PersonRole.Editor);
+ Assert.Contains(series2.Metadata.People, p => p.Role == PersonRole.Colorist);
+
+
+ }
+
+ [Fact]
+ public async Task PersonAddAlias_NoOverlap()
+ {
+ await ResetDb();
+
+ UnitOfWork.PersonRepository.Attach(new PersonBuilder("Jillian Cowan").Build());
+ UnitOfWork.PersonRepository.Attach(new PersonBuilder("Jilly Cowan").WithAlias("Jolly Cowan").Build());
+ await UnitOfWork.CommitAsync();
+
+ var ps = new PersonService(UnitOfWork);
+
+ var person1 = await UnitOfWork.PersonRepository.GetPersonByNameOrAliasAsync("Jillian Cowan");
+ var person2 = await UnitOfWork.PersonRepository.GetPersonByNameOrAliasAsync("Jilly Cowan");
+ Assert.NotNull(person1);
+ Assert.NotNull(person2);
+
+ // Overlap on Name
+ var success = await ps.UpdatePersonAliasesAsync(person1, ["Jilly Cowan"]);
+ Assert.False(success);
+
+ // Overlap on alias
+ success = await ps.UpdatePersonAliasesAsync(person1, ["Jolly Cowan"]);
+ Assert.False(success);
+
+ // No overlap
+ success = await ps.UpdatePersonAliasesAsync(person2, ["Jilly Joy Cowan"]);
+ Assert.True(success);
+
+ // Some overlap
+ success = await ps.UpdatePersonAliasesAsync(person1, ["Jolly Cowan", "Jilly Joy Cowan"]);
+ Assert.False(success);
+
+ // Some overlap
+ success = await ps.UpdatePersonAliasesAsync(person1, ["Jolly Cowan", "Jilly Joy Cowan"]);
+ Assert.False(success);
+
+ Assert.Single(person2.Aliases);
+ }
+
+ protected override async Task ResetDb()
+ {
+ Context.Person.RemoveRange(Context.Person.ToList());
+
+ await Context.SaveChangesAsync();
+ }
+}
diff --git a/API.Tests/Services/ReadingProfileServiceTest.cs b/API.Tests/Services/ReadingProfileServiceTest.cs
new file mode 100644
index 000000000..b3d81e5ac
--- /dev/null
+++ b/API.Tests/Services/ReadingProfileServiceTest.cs
@@ -0,0 +1,561 @@
+using System.Linq;
+using System.Threading.Tasks;
+using API.Data.Repositories;
+using API.DTOs;
+using API.Entities;
+using API.Entities.Enums;
+using API.Helpers.Builders;
+using API.Services;
+using API.Tests.Helpers;
+using Kavita.Common;
+using Microsoft.EntityFrameworkCore;
+using NSubstitute;
+using Xunit;
+
+namespace API.Tests.Services;
+
+public class ReadingProfileServiceTest: AbstractDbTest
+{
+
+ ///
+ /// Does not add a default reading profile
+ ///
+ ///
+ public async Task<(ReadingProfileService, AppUser, Library, Series)> Setup()
+ {
+ var user = new AppUserBuilder("amelia", "amelia@localhost").Build();
+ Context.AppUser.Add(user);
+ await UnitOfWork.CommitAsync();
+
+ var series = new SeriesBuilder("Spice and Wolf").Build();
+
+ var library = new LibraryBuilder("Manga")
+ .WithSeries(series)
+ .Build();
+
+ user.Libraries.Add(library);
+ await UnitOfWork.CommitAsync();
+
+ var rps = new ReadingProfileService(UnitOfWork, Substitute.For(), Mapper);
+ user = await UnitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.UserPreferences);
+
+ return (rps, user, library, series);
+ }
+
+ [Fact]
+ public async Task ImplicitProfileFirst()
+ {
+ await ResetDb();
+ var (rps, user, library, series) = await Setup();
+
+ var profile = new AppUserReadingProfileBuilder(user.Id)
+ .WithKind(ReadingProfileKind.Implicit)
+ .WithSeries(series)
+ .WithName("Implicit Profile")
+ .Build();
+
+ var profile2 = new AppUserReadingProfileBuilder(user.Id)
+ .WithSeries(series)
+ .WithName("Non-implicit Profile")
+ .Build();
+
+ user.ReadingProfiles.Add(profile);
+ user.ReadingProfiles.Add(profile2);
+ await UnitOfWork.CommitAsync();
+
+ var seriesProfile = await rps.GetReadingProfileDtoForSeries(user.Id, series.Id);
+ Assert.NotNull(seriesProfile);
+ Assert.Equal("Implicit Profile", seriesProfile.Name);
+
+ // Find parent
+ seriesProfile = await rps.GetReadingProfileDtoForSeries(user.Id, series.Id, true);
+ Assert.NotNull(seriesProfile);
+ Assert.Equal("Non-implicit Profile", seriesProfile.Name);
+ }
+
+ [Fact]
+ public async Task CantDeleteDefaultReadingProfile()
+ {
+ await ResetDb();
+ var (rps, user, _, _) = await Setup();
+
+ var profile = new AppUserReadingProfileBuilder(user.Id)
+ .WithKind(ReadingProfileKind.Default)
+ .Build();
+ Context.AppUserReadingProfiles.Add(profile);
+ await UnitOfWork.CommitAsync();
+
+ await Assert.ThrowsAsync(async () =>
+ {
+ await rps.DeleteReadingProfile(user.Id, profile.Id);
+ });
+
+ var profile2 = new AppUserReadingProfileBuilder(user.Id).Build();
+ Context.AppUserReadingProfiles.Add(profile2);
+ await UnitOfWork.CommitAsync();
+
+ await rps.DeleteReadingProfile(user.Id, profile2.Id);
+ await UnitOfWork.CommitAsync();
+
+ var allProfiles = await Context.AppUserReadingProfiles.ToListAsync();
+ Assert.Single(allProfiles);
+ }
+
+ [Fact]
+ public async Task CreateImplicitSeriesReadingProfile()
+ {
+ await ResetDb();
+ var (rps, user, _, series) = await Setup();
+
+ var dto = new UserReadingProfileDto
+ {
+ ReaderMode = ReaderMode.Webtoon,
+ ScalingOption = ScalingOption.FitToHeight,
+ WidthOverride = 53,
+ };
+
+ await rps.UpdateImplicitReadingProfile(user.Id, series.Id, dto);
+
+ var profile = await rps.GetReadingProfileForSeries(user.Id, series.Id);
+ Assert.NotNull(profile);
+ Assert.Contains(profile.SeriesIds, s => s == series.Id);
+ Assert.Equal(ReadingProfileKind.Implicit, profile.Kind);
+ }
+
+ [Fact]
+ public async Task UpdateImplicitReadingProfile_DoesNotCreateNew()
+ {
+ await ResetDb();
+ var (rps, user, _, series) = await Setup();
+
+ var dto = new UserReadingProfileDto
+ {
+ ReaderMode = ReaderMode.Webtoon,
+ ScalingOption = ScalingOption.FitToHeight,
+ WidthOverride = 53,
+ };
+
+ await rps.UpdateImplicitReadingProfile(user.Id, series.Id, dto);
+
+ var profile = await rps.GetReadingProfileForSeries(user.Id, series.Id);
+ Assert.NotNull(profile);
+ Assert.Contains(profile.SeriesIds, s => s == series.Id);
+ Assert.Equal(ReadingProfileKind.Implicit, profile.Kind);
+
+ dto = new UserReadingProfileDto
+ {
+ ReaderMode = ReaderMode.LeftRight,
+ };
+
+ await rps.UpdateImplicitReadingProfile(user.Id, series.Id, dto);
+ profile = await rps.GetReadingProfileForSeries(user.Id, series.Id);
+ Assert.NotNull(profile);
+ Assert.Contains(profile.SeriesIds, s => s == series.Id);
+ Assert.Equal(ReadingProfileKind.Implicit, profile.Kind);
+ Assert.Equal(ReaderMode.LeftRight, profile.ReaderMode);
+
+ var implicitCount = await Context.AppUserReadingProfiles
+ .Where(p => p.Kind == ReadingProfileKind.Implicit)
+ .CountAsync();
+ Assert.Equal(1, implicitCount);
+ }
+
+ [Fact]
+ public async Task GetCorrectProfile()
+ {
+ await ResetDb();
+ var (rps, user, lib, series) = await Setup();
+
+ var profile = new AppUserReadingProfileBuilder(user.Id)
+ .WithSeries(series)
+ .WithName("Series Specific")
+ .Build();
+ var profile2 = new AppUserReadingProfileBuilder(user.Id)
+ .WithLibrary(lib)
+ .WithName("Library Specific")
+ .Build();
+ var profile3 = new AppUserReadingProfileBuilder(user.Id)
+ .WithKind(ReadingProfileKind.Default)
+ .WithName("Global")
+ .Build();
+ Context.AppUserReadingProfiles.Add(profile);
+ Context.AppUserReadingProfiles.Add(profile2);
+ Context.AppUserReadingProfiles.Add(profile3);
+
+ var series2 = new SeriesBuilder("Rainbows After Storms").Build();
+ lib.Series.Add(series2);
+
+ var lib2 = new LibraryBuilder("Manga2").Build();
+ var series3 = new SeriesBuilder("A Tropical Fish Yearns for Snow").Build();
+ lib2.Series.Add(series3);
+
+ user.Libraries.Add(lib2);
+ await UnitOfWork.CommitAsync();
+
+ var p = await rps.GetReadingProfileDtoForSeries(user.Id, series.Id);
+ Assert.NotNull(p);
+ Assert.Equal("Series Specific", p.Name);
+
+ p = await rps.GetReadingProfileDtoForSeries(user.Id, series2.Id);
+ Assert.NotNull(p);
+ Assert.Equal("Library Specific", p.Name);
+
+ p = await rps.GetReadingProfileDtoForSeries(user.Id, series3.Id);
+ Assert.NotNull(p);
+ Assert.Equal("Global", p.Name);
+ }
+
+ [Fact]
+ public async Task ReplaceReadingProfile()
+ {
+ await ResetDb();
+ var (rps, user, lib, series) = await Setup();
+
+ var profile1 = new AppUserReadingProfileBuilder(user.Id)
+ .WithSeries(series)
+ .WithName("Profile 1")
+ .Build();
+
+ var profile2 = new AppUserReadingProfileBuilder(user.Id)
+ .WithName("Profile 2")
+ .Build();
+
+ Context.AppUserReadingProfiles.Add(profile1);
+ Context.AppUserReadingProfiles.Add(profile2);
+ await UnitOfWork.CommitAsync();
+
+ var profile = await rps.GetReadingProfileDtoForSeries(user.Id, series.Id);
+ Assert.NotNull(profile);
+ Assert.Equal("Profile 1", profile.Name);
+
+ await rps.AddProfileToSeries(user.Id, profile2.Id, series.Id);
+ profile = await rps.GetReadingProfileDtoForSeries(user.Id, series.Id);
+ Assert.NotNull(profile);
+ Assert.Equal("Profile 2", profile.Name);
+ }
+
+ [Fact]
+ public async Task DeleteReadingProfile()
+ {
+ await ResetDb();
+ var (rps, user, lib, series) = await Setup();
+
+ var profile1 = new AppUserReadingProfileBuilder(user.Id)
+ .WithSeries(series)
+ .WithName("Profile 1")
+ .Build();
+
+ Context.AppUserReadingProfiles.Add(profile1);
+ await UnitOfWork.CommitAsync();
+
+ await rps.ClearSeriesProfile(user.Id, series.Id);
+ var profiles = await UnitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(user.Id);
+ Assert.DoesNotContain(profiles, rp => rp.SeriesIds.Contains(series.Id));
+
+ }
+
+ [Fact]
+ public async Task BulkAddReadingProfiles()
+ {
+ await ResetDb();
+ var (rps, user, lib, series) = await Setup();
+
+ for (var i = 0; i < 10; i++)
+ {
+ var generatedSeries = new SeriesBuilder($"Generated Series #{i}").Build();
+ lib.Series.Add(generatedSeries);
+ }
+
+ var profile = new AppUserReadingProfileBuilder(user.Id)
+ .WithSeries(series)
+ .WithName("Profile")
+ .Build();
+ Context.AppUserReadingProfiles.Add(profile);
+
+ var profile2 = new AppUserReadingProfileBuilder(user.Id)
+ .WithSeries(series)
+ .WithName("Profile2")
+ .Build();
+ Context.AppUserReadingProfiles.Add(profile2);
+
+ await UnitOfWork.CommitAsync();
+
+ var someSeriesIds = lib.Series.Take(lib.Series.Count / 2).Select(s => s.Id).ToList();
+ await rps.BulkAddProfileToSeries(user.Id, profile.Id, someSeriesIds);
+
+ foreach (var id in someSeriesIds)
+ {
+ var foundProfile = await rps.GetReadingProfileDtoForSeries(user.Id, id);
+ Assert.NotNull(foundProfile);
+ Assert.Equal(profile.Id, foundProfile.Id);
+ }
+
+ var allIds = lib.Series.Select(s => s.Id).ToList();
+ await rps.BulkAddProfileToSeries(user.Id, profile2.Id, allIds);
+
+ foreach (var id in allIds)
+ {
+ var foundProfile = await rps.GetReadingProfileDtoForSeries(user.Id, id);
+ Assert.NotNull(foundProfile);
+ Assert.Equal(profile2.Id, foundProfile.Id);
+ }
+
+
+ }
+
+ [Fact]
+ public async Task BulkAssignDeletesImplicit()
+ {
+ await ResetDb();
+ var (rps, user, lib, series) = await Setup();
+
+ var implicitProfile = Mapper.Map(new AppUserReadingProfileBuilder(user.Id)
+ .Build());
+
+ var profile = new AppUserReadingProfileBuilder(user.Id)
+ .WithName("Profile 1")
+ .Build();
+ Context.AppUserReadingProfiles.Add(profile);
+
+ for (var i = 0; i < 10; i++)
+ {
+ var generatedSeries = new SeriesBuilder($"Generated Series #{i}").Build();
+ lib.Series.Add(generatedSeries);
+ }
+ await UnitOfWork.CommitAsync();
+
+ var ids = lib.Series.Select(s => s.Id).ToList();
+
+ foreach (var id in ids)
+ {
+ await rps.UpdateImplicitReadingProfile(user.Id, id, implicitProfile);
+ var seriesProfile = await rps.GetReadingProfileDtoForSeries(user.Id, id);
+ Assert.NotNull(seriesProfile);
+ Assert.Equal(ReadingProfileKind.Implicit, seriesProfile.Kind);
+ }
+
+ await rps.BulkAddProfileToSeries(user.Id, profile.Id, ids);
+
+ foreach (var id in ids)
+ {
+ var seriesProfile = await rps.GetReadingProfileDtoForSeries(user.Id, id);
+ Assert.NotNull(seriesProfile);
+ Assert.Equal(ReadingProfileKind.User, seriesProfile.Kind);
+ }
+
+ var implicitCount = await Context.AppUserReadingProfiles
+ .Where(p => p.Kind == ReadingProfileKind.Implicit)
+ .CountAsync();
+ Assert.Equal(0, implicitCount);
+ }
+
+ [Fact]
+ public async Task AddDeletesImplicit()
+ {
+ await ResetDb();
+ var (rps, user, lib, series) = await Setup();
+
+ var implicitProfile = Mapper.Map(new AppUserReadingProfileBuilder(user.Id)
+ .WithKind(ReadingProfileKind.Implicit)
+ .Build());
+
+ var profile = new AppUserReadingProfileBuilder(user.Id)
+ .WithName("Profile 1")
+ .Build();
+ Context.AppUserReadingProfiles.Add(profile);
+ await UnitOfWork.CommitAsync();
+
+ await rps.UpdateImplicitReadingProfile(user.Id, series.Id, implicitProfile);
+
+ var seriesProfile = await rps.GetReadingProfileDtoForSeries(user.Id, series.Id);
+ Assert.NotNull(seriesProfile);
+ Assert.Equal(ReadingProfileKind.Implicit, seriesProfile.Kind);
+
+ await rps.AddProfileToSeries(user.Id, profile.Id, series.Id);
+
+ seriesProfile = await rps.GetReadingProfileDtoForSeries(user.Id, series.Id);
+ Assert.NotNull(seriesProfile);
+ Assert.Equal(ReadingProfileKind.User, seriesProfile.Kind);
+
+ var implicitCount = await Context.AppUserReadingProfiles
+ .Where(p => p.Kind == ReadingProfileKind.Implicit)
+ .CountAsync();
+ Assert.Equal(0, implicitCount);
+ }
+
+ [Fact]
+ public async Task CreateReadingProfile()
+ {
+ await ResetDb();
+ var (rps, user, lib, series) = await Setup();
+
+ var dto = new UserReadingProfileDto
+ {
+ Name = "Profile 1",
+ ReaderMode = ReaderMode.LeftRight,
+ EmulateBook = false,
+ };
+
+ await rps.CreateReadingProfile(user.Id, dto);
+
+ var dto2 = new UserReadingProfileDto
+ {
+ Name = "Profile 2",
+ ReaderMode = ReaderMode.LeftRight,
+ EmulateBook = false,
+ };
+
+ await rps.CreateReadingProfile(user.Id, dto2);
+
+ var dto3 = new UserReadingProfileDto
+ {
+ Name = "Profile 1", // Not unique name
+ ReaderMode = ReaderMode.LeftRight,
+ EmulateBook = false,
+ };
+
+ await Assert.ThrowsAsync(async () =>
+ {
+ await rps.CreateReadingProfile(user.Id, dto3);
+ });
+
+ var allProfiles = Context.AppUserReadingProfiles.ToList();
+ Assert.Equal(2, allProfiles.Count);
+ }
+
+ [Fact]
+ public async Task ClearSeriesProfile_RemovesImplicitAndUnlinksExplicit()
+ {
+ await ResetDb();
+ var (rps, user, _, series) = await Setup();
+
+ var implicitProfile = new AppUserReadingProfileBuilder(user.Id)
+ .WithSeries(series)
+ .WithKind(ReadingProfileKind.Implicit)
+ .WithName("Implicit Profile")
+ .Build();
+
+ var explicitProfile = new AppUserReadingProfileBuilder(user.Id)
+ .WithSeries(series)
+ .WithName("Explicit Profile")
+ .Build();
+
+ Context.AppUserReadingProfiles.Add(implicitProfile);
+ Context.AppUserReadingProfiles.Add(explicitProfile);
+ await UnitOfWork.CommitAsync();
+
+ var allBefore = await UnitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(user.Id);
+ Assert.Equal(2, allBefore.Count(rp => rp.SeriesIds.Contains(series.Id)));
+
+ await rps.ClearSeriesProfile(user.Id, series.Id);
+
+ var remainingProfiles = await Context.AppUserReadingProfiles.ToListAsync();
+ Assert.Single(remainingProfiles);
+ Assert.Equal("Explicit Profile", remainingProfiles[0].Name);
+ Assert.Empty(remainingProfiles[0].SeriesIds);
+
+ var profilesForSeries = await UnitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(user.Id);
+ Assert.DoesNotContain(profilesForSeries, rp => rp.SeriesIds.Contains(series.Id));
+ }
+
+ [Fact]
+ public async Task AddProfileToLibrary_AddsAndOverridesExisting()
+ {
+ await ResetDb();
+ var (rps, user, lib, _) = await Setup();
+
+ var profile = new AppUserReadingProfileBuilder(user.Id)
+ .WithName("Library Profile")
+ .Build();
+ Context.AppUserReadingProfiles.Add(profile);
+ await UnitOfWork.CommitAsync();
+
+ await rps.AddProfileToLibrary(user.Id, profile.Id, lib.Id);
+ await UnitOfWork.CommitAsync();
+
+ var linkedProfile = (await UnitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(user.Id))
+ .FirstOrDefault(rp => rp.LibraryIds.Contains(lib.Id));
+ Assert.NotNull(linkedProfile);
+ Assert.Equal(profile.Id, linkedProfile.Id);
+
+ var newProfile = new AppUserReadingProfileBuilder(user.Id)
+ .WithName("New Profile")
+ .Build();
+ Context.AppUserReadingProfiles.Add(newProfile);
+ await UnitOfWork.CommitAsync();
+
+ await rps.AddProfileToLibrary(user.Id, newProfile.Id, lib.Id);
+ await UnitOfWork.CommitAsync();
+
+ linkedProfile = (await UnitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(user.Id))
+ .FirstOrDefault(rp => rp.LibraryIds.Contains(lib.Id));
+ Assert.NotNull(linkedProfile);
+ Assert.Equal(newProfile.Id, linkedProfile.Id);
+ }
+
+ [Fact]
+ public async Task ClearLibraryProfile_RemovesImplicitOrUnlinksExplicit()
+ {
+ await ResetDb();
+ var (rps, user, lib, _) = await Setup();
+
+ var implicitProfile = new AppUserReadingProfileBuilder(user.Id)
+ .WithKind(ReadingProfileKind.Implicit)
+ .WithLibrary(lib)
+ .Build();
+ Context.AppUserReadingProfiles.Add(implicitProfile);
+ await UnitOfWork.CommitAsync();
+
+ await rps.ClearLibraryProfile(user.Id, lib.Id);
+ var profile = (await UnitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(user.Id))
+ .FirstOrDefault(rp => rp.LibraryIds.Contains(lib.Id));
+ Assert.Null(profile);
+
+ var explicitProfile = new AppUserReadingProfileBuilder(user.Id)
+ .WithLibrary(lib)
+ .Build();
+ Context.AppUserReadingProfiles.Add(explicitProfile);
+ await UnitOfWork.CommitAsync();
+
+ await rps.ClearLibraryProfile(user.Id, lib.Id);
+ profile = (await UnitOfWork.AppUserReadingProfileRepository.GetProfilesForUser(user.Id))
+ .FirstOrDefault(rp => rp.LibraryIds.Contains(lib.Id));
+ Assert.Null(profile);
+
+ var stillExists = await Context.AppUserReadingProfiles.FindAsync(explicitProfile.Id);
+ Assert.NotNull(stillExists);
+ }
+
+ ///
+ /// As response to #3793, I'm not sure if we want to keep this. It's not the most nice. But I think the idea of this test
+ /// is worth having.
+ ///
+ [Fact]
+ public void UpdateFields_UpdatesAll()
+ {
+ // Repeat to ensure booleans are flipped and actually tested
+ for (int i = 0; i < 10; i++)
+ {
+ var profile = new AppUserReadingProfile();
+ var dto = new UserReadingProfileDto();
+
+ RandfHelper.SetRandomValues(profile);
+ RandfHelper.SetRandomValues(dto);
+
+ ReadingProfileService.UpdateReaderProfileFields(profile, dto);
+
+ var newDto = Mapper.Map(profile);
+
+ Assert.True(RandfHelper.AreSimpleFieldsEqual(dto, newDto,
+ ["k__BackingField", "k__BackingField"]));
+ }
+ }
+
+
+
+ protected override async Task ResetDb()
+ {
+ Context.AppUserReadingProfiles.RemoveRange(Context.AppUserReadingProfiles);
+ await UnitOfWork.CommitAsync();
+ }
+}
diff --git a/API.Tests/Services/ScannerServiceTests.cs b/API.Tests/Services/ScannerServiceTests.cs
index 2e812647b..c337d2311 100644
--- a/API.Tests/Services/ScannerServiceTests.cs
+++ b/API.Tests/Services/ScannerServiceTests.cs
@@ -483,7 +483,7 @@ public class ScannerServiceTests : AbstractDbTest
var infos = new Dictionary();
var library = await _scannerHelper.GenerateScannerData(testcase, infos);
- library.LibraryExcludePatterns = [new LibraryExcludePattern() {Pattern = "**/Extra/*"}];
+ library.LibraryExcludePatterns = [new LibraryExcludePattern() { Pattern = "**/Extra/*" }];
UnitOfWork.LibraryRepository.Update(library);
await UnitOfWork.CommitAsync();
@@ -507,7 +507,7 @@ public class ScannerServiceTests : AbstractDbTest
var infos = new Dictionary();
var library = await _scannerHelper.GenerateScannerData(testcase, infos);
- library.LibraryExcludePatterns = [new LibraryExcludePattern() {Pattern = "**\\Extra\\*"}];
+ library.LibraryExcludePatterns = [new LibraryExcludePattern() { Pattern = "**\\Extra\\*" }];
UnitOfWork.LibraryRepository.Update(library);
await UnitOfWork.CommitAsync();
@@ -938,4 +938,61 @@ public class ScannerServiceTests : AbstractDbTest
Assert.True(sortedChapters[1].SortOrder.Is(4f));
Assert.True(sortedChapters[2].SortOrder.Is(5f));
}
+
+
+ [Fact]
+ public async Task ScanLibrary_MetadataDisabled_NoOverrides()
+ {
+ const string testcase = "Series with Localized No Metadata - Manga.json";
+
+ // Get the first file and generate a ComicInfo
+ var infos = new Dictionary();
+ infos.Add("Immoral Guild v01.cbz", new ComicInfo()
+ {
+ Series = "Immoral Guild",
+ LocalizedSeries = "Futoku no Guild" // Filename has a capital N and localizedSeries has lowercase
+ });
+
+ var library = await _scannerHelper.GenerateScannerData(testcase, infos);
+
+ // Disable metadata
+ library.EnableMetadata = false;
+ UnitOfWork.LibraryRepository.Update(library);
+ await UnitOfWork.CommitAsync();
+
+ var scanner = _scannerHelper.CreateServices();
+ await scanner.ScanLibrary(library.Id);
+
+ var postLib = await UnitOfWork.LibraryRepository.GetLibraryForIdAsync(library.Id, LibraryIncludes.Series);
+
+ // Validate that there are 2 series
+ Assert.NotNull(postLib);
+ Assert.Equal(2, postLib.Series.Count);
+
+ Assert.Contains(postLib.Series, x => x.Name == "Immoral Guild");
+ Assert.Contains(postLib.Series, x => x.Name == "Futoku No Guild");
+ }
+
+ [Fact]
+ public async Task ScanLibrary_SortName_NoPrefix()
+ {
+ const string testcase = "Series with Prefix - Book.json";
+
+ var library = await _scannerHelper.GenerateScannerData(testcase);
+
+ library.RemovePrefixForSortName = true;
+ UnitOfWork.LibraryRepository.Update(library);
+ await UnitOfWork.CommitAsync();
+
+ var scanner = _scannerHelper.CreateServices();
+ await scanner.ScanLibrary(library.Id);
+
+ var postLib = await UnitOfWork.LibraryRepository.GetLibraryForIdAsync(library.Id, LibraryIncludes.Series);
+
+ Assert.NotNull(postLib);
+ Assert.Equal(1, postLib.Series.Count);
+
+ Assert.Equal("The Avengers", postLib.Series.First().Name);
+ Assert.Equal("Avengers", postLib.Series.First().SortName);
+ }
}
diff --git a/API.Tests/Services/ScrobblingServiceTests.cs b/API.Tests/Services/ScrobblingServiceTests.cs
index 50398a146..9245c8ecd 100644
--- a/API.Tests/Services/ScrobblingServiceTests.cs
+++ b/API.Tests/Services/ScrobblingServiceTests.cs
@@ -1,11 +1,17 @@
-using System.Linq;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
+using API.Data.Repositories;
using API.DTOs.Scrobbling;
+using API.Entities;
using API.Entities.Enums;
+using API.Entities.Scrobble;
using API.Helpers.Builders;
using API.Services;
using API.Services.Plus;
using API.SignalR;
+using Kavita.Common;
using Microsoft.Extensions.Logging;
using NSubstitute;
using Xunit;
@@ -15,11 +21,33 @@ namespace API.Tests.Services;
public class ScrobblingServiceTests : AbstractDbTest
{
+ private const int ChapterPages = 100;
+
+ ///
+ /// {
+ /// "Issuer": "Issuer",
+ /// "Issued At": "2025-06-15T21:01:57.615Z",
+ /// "Expiration": "2200-06-15T21:01:57.615Z"
+ /// }
+ ///
+ /// Our UnitTests will fail in 2200 :(
+ private const string ValidJwtToken =
+ "eyJhbGciOiJIUzI1NiJ9.eyJJc3N1ZXIiOiJJc3N1ZXIiLCJleHAiOjcyNzI0NTAxMTcsImlhdCI6MTc1MDAyMTMxN30.zADmcGq_BfxbcV8vy4xw5Cbzn4COkmVINxgqpuL17Ng";
+
private readonly ScrobblingService _service;
private readonly ILicenseService _licenseService;
private readonly ILocalizationService _localizationService;
private readonly ILogger _logger;
private readonly IEmailService _emailService;
+ private readonly IKavitaPlusApiService _kavitaPlusApiService;
+ ///
+ /// IReaderService, without the ScrobblingService injected
+ ///
+ private readonly IReaderService _readerService;
+ ///
+ /// IReaderService, with the _service injected
+ ///
+ private readonly IReaderService _hookedUpReaderService;
public ScrobblingServiceTests()
{
@@ -27,8 +55,24 @@ public class ScrobblingServiceTests : AbstractDbTest
_localizationService = Substitute.For();
_logger = Substitute.For>();
_emailService = Substitute.For();
+ _kavitaPlusApiService = Substitute.For();
- _service = new ScrobblingService(UnitOfWork, Substitute.For(), _logger, _licenseService, _localizationService, _emailService);
+ _service = new ScrobblingService(UnitOfWork, Substitute.For(), _logger, _licenseService,
+ _localizationService, _emailService, _kavitaPlusApiService);
+
+ _readerService = new ReaderService(UnitOfWork,
+ Substitute.For>(),
+ Substitute.For(),
+ Substitute.For(),
+ Substitute.For(),
+ Substitute.For()); // Do not use the actual one
+
+ _hookedUpReaderService = new ReaderService(UnitOfWork,
+ Substitute.For>(),
+ Substitute.For(),
+ Substitute.For(),
+ Substitute.For(),
+ _service);
}
protected override async Task ResetDb()
@@ -46,6 +90,30 @@ public class ScrobblingServiceTests : AbstractDbTest
var series = new SeriesBuilder("Test Series")
.WithFormat(MangaFormat.Archive)
.WithMetadata(new SeriesMetadataBuilder().Build())
+ .WithVolume(new VolumeBuilder("Volume 1")
+ .WithChapters([
+ new ChapterBuilder("1")
+ .WithPages(ChapterPages)
+ .Build(),
+ new ChapterBuilder("2")
+ .WithPages(ChapterPages)
+ .Build(),
+ new ChapterBuilder("3")
+ .WithPages(ChapterPages)
+ .Build()])
+ .Build())
+ .WithVolume(new VolumeBuilder("Volume 2")
+ .WithChapters([
+ new ChapterBuilder("4")
+ .WithPages(ChapterPages)
+ .Build(),
+ new ChapterBuilder("5")
+ .WithPages(ChapterPages)
+ .Build(),
+ new ChapterBuilder("6")
+ .WithPages(ChapterPages)
+ .Build()])
+ .Build())
.Build();
var library = new LibraryBuilder("Test Library", LibraryType.Manga)
@@ -67,6 +135,296 @@ public class ScrobblingServiceTests : AbstractDbTest
await UnitOfWork.CommitAsync();
}
+ private async Task CreateScrobbleEvent(int? seriesId = null)
+ {
+ var evt = new ScrobbleEvent
+ {
+ ScrobbleEventType = ScrobbleEventType.ChapterRead,
+ Format = PlusMediaFormat.Manga,
+ SeriesId = seriesId ?? 0,
+ LibraryId = 0,
+ AppUserId = 0,
+ };
+
+ if (seriesId != null)
+ {
+ var series = await UnitOfWork.SeriesRepository.GetSeriesByIdAsync(seriesId.Value);
+ if (series != null) evt.Series = series;
+ }
+
+ return evt;
+ }
+
+
+ #region K+ API Request Tests
+
+ [Fact]
+ public async Task PostScrobbleUpdate_AuthErrors()
+ {
+ _kavitaPlusApiService.PostScrobbleUpdate(null!, "")
+ .ReturnsForAnyArgs(new ScrobbleResponseDto()
+ {
+ ErrorMessage = "Unauthorized"
+ });
+
+ var evt = await CreateScrobbleEvent();
+ await Assert.ThrowsAsync(async () =>
+ {
+ await _service.PostScrobbleUpdate(new ScrobbleDto(), "", evt);
+ });
+ Assert.True(evt.IsErrored);
+ Assert.Equal("Kavita+ subscription no longer active", evt.ErrorDetails);
+ }
+
+ [Fact]
+ public async Task PostScrobbleUpdate_UnknownSeriesLoggedAsError()
+ {
+ _kavitaPlusApiService.PostScrobbleUpdate(null!, "")
+ .ReturnsForAnyArgs(new ScrobbleResponseDto()
+ {
+ ErrorMessage = "Unknown Series"
+ });
+
+ await SeedData();
+ var evt = await CreateScrobbleEvent(1);
+
+ await _service.PostScrobbleUpdate(new ScrobbleDto(), "", evt);
+ await UnitOfWork.CommitAsync();
+ Assert.True(evt.IsErrored);
+
+ var series = await UnitOfWork.SeriesRepository.GetSeriesByIdAsync(1);
+ Assert.NotNull(series);
+ Assert.True(series.IsBlacklisted);
+
+ var errors = await UnitOfWork.ScrobbleRepository.GetAllScrobbleErrorsForSeries(1);
+ Assert.Single(errors);
+ Assert.Equal("Series cannot be matched for Scrobbling", errors.First().Comment);
+ Assert.Equal(series.Id, errors.First().SeriesId);
+ }
+
+ [Fact]
+ public async Task PostScrobbleUpdate_InvalidAccessToken()
+ {
+ _kavitaPlusApiService.PostScrobbleUpdate(null!, "")
+ .ReturnsForAnyArgs(new ScrobbleResponseDto()
+ {
+ ErrorMessage = "Access token is invalid"
+ });
+
+ var evt = await CreateScrobbleEvent();
+
+ await Assert.ThrowsAsync(async () =>
+ {
+ await _service.PostScrobbleUpdate(new ScrobbleDto(), "", evt);
+ });
+
+ Assert.True(evt.IsErrored);
+ Assert.Equal("Access Token needs to be rotated to continue scrobbling", evt.ErrorDetails);
+ }
+
+ #endregion
+
+ #region K+ API Request data tests
+
+ [Fact]
+ public async Task ProcessReadEvents_CreatesNoEventsWhenNoProgress()
+ {
+ await ResetDb();
+ await SeedData();
+
+ // Set Returns
+ _licenseService.HasActiveLicense().Returns(Task.FromResult(true));
+ _kavitaPlusApiService.GetRateLimit(Arg.Any(), Arg.Any())
+ .Returns(100);
+
+ var user = await UnitOfWork.UserRepository.GetUserByIdAsync(1);
+ Assert.NotNull(user);
+
+ // Ensure CanProcessScrobbleEvent returns true
+ user.AniListAccessToken = ValidJwtToken;
+ UnitOfWork.UserRepository.Update(user);
+ await UnitOfWork.CommitAsync();
+
+ var chapter = await UnitOfWork.ChapterRepository.GetChapterAsync(4);
+ Assert.NotNull(chapter);
+
+ var volume = await UnitOfWork.VolumeRepository.GetVolumeAsync(1, VolumeIncludes.Chapters);
+ Assert.NotNull(volume);
+
+ // Call Scrobble without having any progress
+ await _service.ScrobbleReadingUpdate(1, 1);
+ var events = await UnitOfWork.ScrobbleRepository.GetAllEventsForSeries(1);
+ Assert.Empty(events);
+ }
+
+ [Fact]
+ public async Task ProcessReadEvents_UpdateVolumeAndChapterData()
+ {
+ await ResetDb();
+ await SeedData();
+
+ // Set Returns
+ _licenseService.HasActiveLicense().Returns(Task.FromResult(true));
+ _kavitaPlusApiService.GetRateLimit(Arg.Any(), Arg.Any())
+ .Returns(100);
+
+ var user = await UnitOfWork.UserRepository.GetUserByIdAsync(1);
+ Assert.NotNull(user);
+
+ // Ensure CanProcessScrobbleEvent returns true
+ user.AniListAccessToken = ValidJwtToken;
+ UnitOfWork.UserRepository.Update(user);
+ await UnitOfWork.CommitAsync();
+
+ var chapter = await UnitOfWork.ChapterRepository.GetChapterAsync(4);
+ Assert.NotNull(chapter);
+
+ var volume = await UnitOfWork.VolumeRepository.GetVolumeAsync(1, VolumeIncludes.Chapters);
+ Assert.NotNull(volume);
+
+ // Mark something as read to trigger event creation
+ await _readerService.MarkChaptersAsRead(user, 1, new List() {volume.Chapters[0]});
+ await UnitOfWork.CommitAsync();
+
+ // Call Scrobble while having some progress
+ await _service.ScrobbleReadingUpdate(user.Id, 1);
+ var events = await UnitOfWork.ScrobbleRepository.GetAllEventsForSeries(1);
+ Assert.Single(events);
+
+ // Give it some (more) read progress
+ await _readerService.MarkChaptersAsRead(user, 1, volume.Chapters);
+ await _readerService.MarkChaptersAsRead(user, 1, [chapter]);
+ await UnitOfWork.CommitAsync();
+
+ await _service.ProcessUpdatesSinceLastSync();
+
+ await _kavitaPlusApiService.Received(1).PostScrobbleUpdate(
+ Arg.Is(data =>
+ data.ChapterNumber == (int)chapter.MaxNumber &&
+ data.VolumeNumber == (int)volume.MaxNumber
+ ),
+ Arg.Any());
+ }
+
+ #endregion
+
+ #region Scrobble Reading Update Tests
+
+ [Fact]
+ public async Task ScrobbleReadingUpdate_IgnoreNoLicense()
+ {
+ await ResetDb();
+ await SeedData();
+
+ _licenseService.HasActiveLicense().Returns(false);
+
+ await _service.ScrobbleReadingUpdate(1, 1);
+ var events = await UnitOfWork.ScrobbleRepository.GetAllEventsForSeries(1);
+ Assert.Empty(events);
+ }
+
+ [Fact]
+ public async Task ScrobbleReadingUpdate_RemoveWhenNoProgress()
+ {
+ await ResetDb();
+ await SeedData();
+
+ _licenseService.HasActiveLicense().Returns(true);
+
+ var user = await UnitOfWork.UserRepository.GetUserByIdAsync(1);
+ Assert.NotNull(user);
+
+ var volume = await UnitOfWork.VolumeRepository.GetVolumeAsync(1, VolumeIncludes.Chapters);
+ Assert.NotNull(volume);
+
+ await _readerService.MarkChaptersAsRead(user, 1, new List() {volume.Chapters[0]});
+ await UnitOfWork.CommitAsync();
+
+ await _service.ScrobbleReadingUpdate(1, 1);
+ var events = await UnitOfWork.ScrobbleRepository.GetAllEventsForSeries(1);
+ Assert.Single(events);
+
+ var readEvent = events.First();
+ Assert.False(readEvent.IsProcessed);
+
+ await _hookedUpReaderService.MarkSeriesAsUnread(user, 1);
+ await UnitOfWork.CommitAsync();
+
+ // Existing event is deleted
+ await _service.ScrobbleReadingUpdate(1, 1);
+ events = await UnitOfWork.ScrobbleRepository.GetAllEventsForSeries(1);
+ Assert.Empty(events);
+
+ await _hookedUpReaderService.MarkSeriesAsUnread(user, 1);
+ await UnitOfWork.CommitAsync();
+
+ // No new events are added
+ events = await UnitOfWork.ScrobbleRepository.GetAllEventsForSeries(1);
+ Assert.Empty(events);
+ }
+
+ [Fact]
+ public async Task ScrobbleReadingUpdate_UpdateExistingNotIsProcessed()
+ {
+ await ResetDb();
+ await SeedData();
+
+ var user = await UnitOfWork.UserRepository.GetUserByIdAsync(1);
+ Assert.NotNull(user);
+
+ var chapter1 = await UnitOfWork.ChapterRepository.GetChapterAsync(1);
+ var chapter2 = await UnitOfWork.ChapterRepository.GetChapterAsync(2);
+ var chapter3 = await UnitOfWork.ChapterRepository.GetChapterAsync(3);
+ Assert.NotNull(chapter1);
+ Assert.NotNull(chapter2);
+ Assert.NotNull(chapter3);
+
+ _licenseService.HasActiveLicense().Returns(true);
+
+ var events = await UnitOfWork.ScrobbleRepository.GetAllEventsForSeries(1);
+ Assert.Empty(events);
+
+
+ await _readerService.MarkChaptersAsRead(user, 1, [chapter1]);
+ await UnitOfWork.CommitAsync();
+
+ // Scrobble update
+ await _service.ScrobbleReadingUpdate(1, 1);
+ events = await UnitOfWork.ScrobbleRepository.GetAllEventsForSeries(1);
+ Assert.Single(events);
+
+ var readEvent = events[0];
+ Assert.False(readEvent.IsProcessed);
+ Assert.Equal(1, readEvent.ChapterNumber);
+
+ // Mark as processed
+ readEvent.IsProcessed = true;
+ await UnitOfWork.CommitAsync();
+
+ await _readerService.MarkChaptersAsRead(user, 1, [chapter2]);
+ await UnitOfWork.CommitAsync();
+
+ // Scrobble update
+ await _service.ScrobbleReadingUpdate(1, 1);
+ events = await UnitOfWork.ScrobbleRepository.GetAllEventsForSeries(1);
+ Assert.Equal(2, events.Count);
+ Assert.Single(events.Where(e => e.IsProcessed).ToList());
+ Assert.Single(events.Where(e => !e.IsProcessed).ToList());
+
+ // Should update the existing non processed event
+ await _readerService.MarkChaptersAsRead(user, 1, [chapter3]);
+ await UnitOfWork.CommitAsync();
+
+ // Scrobble update
+ await _service.ScrobbleReadingUpdate(1, 1);
+ events = await UnitOfWork.ScrobbleRepository.GetAllEventsForSeries(1);
+ Assert.Equal(2, events.Count);
+ Assert.Single(events.Where(e => e.IsProcessed).ToList());
+ Assert.Single(events.Where(e => !e.IsProcessed).ToList());
+ }
+
+ #endregion
+
#region ScrobbleWantToReadUpdate Tests
[Fact]
@@ -203,6 +561,59 @@ public class ScrobblingServiceTests : AbstractDbTest
#endregion
+ #region Scrobble Rating Update Test
+
+ [Fact]
+ public async Task ScrobbleRatingUpdate_IgnoreNoLicense()
+ {
+ await ResetDb();
+ await SeedData();
+
+ _licenseService.HasActiveLicense().Returns(false);
+
+ await _service.ScrobbleRatingUpdate(1, 1, 1);
+ var events = await UnitOfWork.ScrobbleRepository.GetAllEventsForSeries(1);
+ Assert.Empty(events);
+ }
+
+ [Fact]
+ public async Task ScrobbleRatingUpdate_UpdateExistingNotIsProcessed()
+ {
+ await ResetDb();
+ await SeedData();
+
+ _licenseService.HasActiveLicense().Returns(true);
+
+ var user = await UnitOfWork.UserRepository.GetUserByIdAsync(1);
+ Assert.NotNull(user);
+
+ var series = await UnitOfWork.SeriesRepository.GetSeriesByIdAsync(1);
+ Assert.NotNull(series);
+
+ await _service.ScrobbleRatingUpdate(user.Id, series.Id, 1);
+ var events = await UnitOfWork.ScrobbleRepository.GetAllEventsForSeries(1);
+ Assert.Single(events);
+ Assert.Equal(1, events.First().Rating);
+
+ // Mark as processed
+ events.First().IsProcessed = true;
+ await UnitOfWork.CommitAsync();
+
+ await _service.ScrobbleRatingUpdate(user.Id, series.Id, 5);
+ events = await UnitOfWork.ScrobbleRepository.GetAllEventsForSeries(1);
+ Assert.Equal(2, events.Count);
+ Assert.Single(events, evt => evt.IsProcessed);
+ Assert.Single(events, evt => !evt.IsProcessed);
+
+ await _service.ScrobbleRatingUpdate(user.Id, series.Id, 5);
+ events = await UnitOfWork.ScrobbleRepository.GetAllEventsForSeries(1);
+ Assert.Single(events, evt => !evt.IsProcessed);
+ Assert.Equal(5, events.First(evt => !evt.IsProcessed).Rating);
+
+ }
+
+ #endregion
+
[Theory]
[InlineData("https://anilist.co/manga/35851/Byeontaega-Doeja/", 35851)]
[InlineData("https://anilist.co/manga/30105", 30105)]
diff --git a/API.Tests/Services/SeriesServiceTests.cs b/API.Tests/Services/SeriesServiceTests.cs
index 4bf0e6782..55babf815 100644
--- a/API.Tests/Services/SeriesServiceTests.cs
+++ b/API.Tests/Services/SeriesServiceTests.cs
@@ -8,6 +8,7 @@ using API.Data;
using API.Data.Repositories;
using API.DTOs;
using API.DTOs.Metadata;
+using API.DTOs.Person;
using API.DTOs.SeriesDetail;
using API.Entities;
using API.Entities.Enums;
diff --git a/API.Tests/Services/Test Data/ScannerService/TestCases/Series with Localized No Metadata - Manga.json b/API.Tests/Services/Test Data/ScannerService/TestCases/Series with Localized No Metadata - Manga.json
new file mode 100644
index 000000000..d6e91183b
--- /dev/null
+++ b/API.Tests/Services/Test Data/ScannerService/TestCases/Series with Localized No Metadata - Manga.json
@@ -0,0 +1,5 @@
+[
+ "Immoral Guild/Immoral Guild v01.cbz",
+ "Immoral Guild/Immoral Guild v02.cbz",
+ "Immoral Guild/Futoku No Guild - Vol. 12 Ch. 67 - Take Responsibility.cbz"
+]
diff --git a/API.Tests/Services/Test Data/ScannerService/TestCases/Series with Prefix - Book.json b/API.Tests/Services/Test Data/ScannerService/TestCases/Series with Prefix - Book.json
new file mode 100644
index 000000000..fc2bee18c
--- /dev/null
+++ b/API.Tests/Services/Test Data/ScannerService/TestCases/Series with Prefix - Book.json
@@ -0,0 +1,3 @@
+[
+ "The Avengers/The Avengers vol 1.pdf"
+]
\ No newline at end of file
diff --git a/API/API.csproj b/API/API.csproj
index 1ddb37d7f..a7d1177dc 100644
--- a/API/API.csproj
+++ b/API/API.csproj
@@ -50,9 +50,9 @@
-
-
-
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -62,45 +62,45 @@
-
+
-
+
-
+
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
-
+
-
-
-
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
+
+
+
+
+
+
@@ -111,17 +111,16 @@
-
-
-
-
-
+
+
+
+
@@ -139,6 +138,7 @@
+
@@ -188,7 +188,6 @@
-
Always
diff --git a/API/Controllers/AccountController.cs b/API/Controllers/AccountController.cs
index c504e1ce7..d8b9164af 100644
--- a/API/Controllers/AccountController.cs
+++ b/API/Controllers/AccountController.cs
@@ -153,6 +153,9 @@ public class AccountController : BaseApiController
// Assign default streams
AddDefaultStreamsToUser(user);
+ // Assign default reading profile
+ await AddDefaultReadingProfileToUser(user);
+
var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);
if (string.IsNullOrEmpty(token)) return BadRequest(await _localizationService.Get("en", "confirm-token-gen"));
if (!await ConfirmEmailToken(token, user)) return BadRequest(await _localizationService.Get("en", "validate-email", token));
@@ -609,7 +612,7 @@ public class AccountController : BaseApiController
}
///
- /// Requests the Invite Url for the UserId. Will return error if user is already validated.
+ /// Requests the Invite Url for the AppUserId. Will return error if user is already validated.
///
///
/// Include the "https://ip:port/" in the generated link
@@ -669,6 +672,9 @@ public class AccountController : BaseApiController
// Assign default streams
AddDefaultStreamsToUser(user);
+ // Assign default reading profile
+ await AddDefaultReadingProfileToUser(user);
+
// Assign Roles
var roles = dto.Roles;
var hasAdminRole = dto.Roles.Contains(PolicyConstants.AdminRole);
@@ -779,6 +785,16 @@ public class AccountController : BaseApiController
}
}
+ private async Task AddDefaultReadingProfileToUser(AppUser user)
+ {
+ var profile = new AppUserReadingProfileBuilder(user.Id)
+ .WithName("Default Profile")
+ .WithKind(ReadingProfileKind.Default)
+ .Build();
+ _unitOfWork.AppUserReadingProfileRepository.Add(profile);
+ await _unitOfWork.CommitAsync();
+ }
+
///
/// Last step in authentication flow, confirms the email token for email
///
diff --git a/API/Controllers/ChapterController.cs b/API/Controllers/ChapterController.cs
index 8de26cf97..94535d499 100644
--- a/API/Controllers/ChapterController.cs
+++ b/API/Controllers/ChapterController.cs
@@ -9,6 +9,7 @@ using API.DTOs;
using API.DTOs.SeriesDetail;
using API.Entities;
using API.Entities.Enums;
+using API.Entities.MetadataMatching;
using API.Entities.Person;
using API.Extensions;
using API.Helpers;
@@ -208,6 +209,7 @@ public class ChapterController : BaseApiController
if (chapter.AgeRating != dto.AgeRating)
{
chapter.AgeRating = dto.AgeRating;
+ chapter.KPlusOverrides.Remove(MetadataSettingField.AgeRating);
}
dto.Summary ??= string.Empty;
@@ -215,6 +217,7 @@ public class ChapterController : BaseApiController
if (chapter.Summary != dto.Summary.Trim())
{
chapter.Summary = dto.Summary.Trim();
+ chapter.KPlusOverrides.Remove(MetadataSettingField.ChapterSummary);
}
if (chapter.Language != dto.Language)
@@ -230,11 +233,13 @@ public class ChapterController : BaseApiController
if (chapter.TitleName != dto.TitleName)
{
chapter.TitleName = dto.TitleName;
+ chapter.KPlusOverrides.Remove(MetadataSettingField.ChapterTitle);
}
if (chapter.ReleaseDate != dto.ReleaseDate)
{
chapter.ReleaseDate = dto.ReleaseDate;
+ chapter.KPlusOverrides.Remove(MetadataSettingField.ChapterReleaseDate);
}
if (!string.IsNullOrEmpty(dto.ISBN) && ArticleNumberHelper.IsValidIsbn10(dto.ISBN) ||
@@ -333,6 +338,8 @@ public class ChapterController : BaseApiController
_unitOfWork
);
+ // TODO: Only remove field if changes were made
+ chapter.KPlusOverrides.Remove(MetadataSettingField.ChapterPublisher);
// Update publishers
await PersonHelper.UpdateChapterPeopleAsync(
chapter,
diff --git a/API/Controllers/KoreaderController.cs b/API/Controllers/KoreaderController.cs
new file mode 100644
index 000000000..8c4c41585
--- /dev/null
+++ b/API/Controllers/KoreaderController.cs
@@ -0,0 +1,119 @@
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using System;
+using System.Threading.Tasks;
+using API.Data;
+using API.Data.Repositories;
+using API.DTOs.Koreader;
+using API.Entities;
+using API.Extensions;
+using API.Services;
+using Kavita.Common;
+using Microsoft.AspNetCore.Identity;
+using Microsoft.Extensions.Logging;
+using static System.Net.WebRequestMethods;
+
+namespace API.Controllers;
+#nullable enable
+
+///
+/// The endpoint to interface with Koreader's Progress Sync plugin.
+///
+///
+/// Koreader uses a different form of authentication. It stores the username and password in headers.
+/// https://github.com/koreader/koreader/blob/master/plugins/kosync.koplugin/KOSyncClient.lua
+///
+[AllowAnonymous]
+public class KoreaderController : BaseApiController
+{
+
+ private readonly IUnitOfWork _unitOfWork;
+ private readonly ILocalizationService _localizationService;
+ private readonly IKoreaderService _koreaderService;
+ private readonly ILogger _logger;
+
+ public KoreaderController(IUnitOfWork unitOfWork, ILocalizationService localizationService,
+ IKoreaderService koreaderService, ILogger logger)
+ {
+ _unitOfWork = unitOfWork;
+ _localizationService = localizationService;
+ _koreaderService = koreaderService;
+ _logger = logger;
+ }
+
+ // We won't allow users to be created from Koreader. Rather, they
+ // must already have an account.
+ /*
+ [HttpPost("/users/create")]
+ public IActionResult CreateUser(CreateUserRequest request)
+ {
+ }
+ */
+
+ [HttpGet("{apiKey}/users/auth")]
+ public async Task Authenticate(string apiKey)
+ {
+ var userId = await GetUserId(apiKey);
+ var user = await _unitOfWork.UserRepository.GetUserByIdAsync(userId);
+ if (user == null) return Unauthorized();
+
+ return Ok(new { username = user.UserName });
+ }
+
+ ///
+ /// Syncs book progress with Kavita. Will attempt to save the underlying reader position if possible.
+ ///
+ ///
+ ///
+ ///
+ [HttpPut("{apiKey}/syncs/progress")]
+ public async Task> UpdateProgress(string apiKey, KoreaderBookDto request)
+ {
+ try
+ {
+ var userId = await GetUserId(apiKey);
+ await _koreaderService.SaveProgress(request, userId);
+
+ return Ok(new KoreaderProgressUpdateDto{ Document = request.Document, Timestamp = DateTime.UtcNow });
+ }
+ catch (KavitaException ex)
+ {
+ return BadRequest(ex.Message);
+ }
+ }
+
+ ///
+ /// Gets book progress from Kavita, if not found will return a 400
+ ///
+ ///
+ ///
+ ///
+ [HttpGet("{apiKey}/syncs/progress/{ebookHash}")]
+ public async Task> GetProgress(string apiKey, string ebookHash)
+ {
+ try
+ {
+ var userId = await GetUserId(apiKey);
+ var response = await _koreaderService.GetProgress(ebookHash, userId);
+ _logger.LogDebug("Koreader response progress for User ({UserId}): {Progress}", userId, response.Progress.Sanitize());
+
+ return Ok(response);
+ }
+ catch (KavitaException ex)
+ {
+ return BadRequest(ex.Message);
+ }
+ }
+
+ private async Task GetUserId(string apiKey)
+ {
+ try
+ {
+ return await _unitOfWork.UserRepository.GetUserIdByApiKeyAsync(apiKey);
+ }
+ catch
+ {
+ throw new KavitaException(await _localizationService.Get("en", "user-doesnt-exist"));
+ }
+ }
+}
diff --git a/API/Controllers/LibraryController.cs b/API/Controllers/LibraryController.cs
index 2f12aa1fe..8f9b18317 100644
--- a/API/Controllers/LibraryController.cs
+++ b/API/Controllers/LibraryController.cs
@@ -623,6 +623,9 @@ public class LibraryController : BaseApiController
library.ManageReadingLists = dto.ManageReadingLists;
library.AllowScrobbling = dto.AllowScrobbling;
library.AllowMetadataMatching = dto.AllowMetadataMatching;
+ library.EnableMetadata = dto.EnableMetadata;
+ library.RemovePrefixForSortName = dto.RemovePrefixForSortName;
+
library.LibraryFileTypes = dto.FileGroupTypes
.Select(t => new LibraryFileTypeGroup() {FileTypeGroup = t, LibraryId = library.Id})
.Distinct()
diff --git a/API/Controllers/MetadataController.cs b/API/Controllers/MetadataController.cs
index b08ac1f38..cab33692a 100644
--- a/API/Controllers/MetadataController.cs
+++ b/API/Controllers/MetadataController.cs
@@ -9,6 +9,8 @@ using API.Data.Repositories;
using API.DTOs;
using API.DTOs.Filtering;
using API.DTOs.Metadata;
+using API.DTOs.Metadata.Browse;
+using API.DTOs.Person;
using API.DTOs.Recommendation;
using API.DTOs.SeriesDetail;
using API.Entities.Enums;
@@ -46,6 +48,22 @@ public class MetadataController(IUnitOfWork unitOfWork, ILocalizationService loc
return Ok(await unitOfWork.GenreRepository.GetAllGenreDtosForLibrariesAsync(User.GetUserId(), ids, context));
}
+ ///
+ /// Returns a list of Genres with counts for counts when Genre is on Series/Chapter
+ ///
+ ///
+ [HttpPost("genres-with-counts")]
+ [ResponseCache(CacheProfileName = ResponseCacheProfiles.FiveMinute)]
+ public async Task>> GetBrowseGenres(UserParams? userParams = null)
+ {
+ userParams ??= UserParams.Default;
+
+ var list = await unitOfWork.GenreRepository.GetBrowseableGenre(User.GetUserId(), userParams);
+ Response.AddPaginationHeader(list.CurrentPage, list.PageSize, list.TotalCount, list.TotalPages);
+
+ return Ok(list);
+ }
+
///
/// Fetches people from the instance by role
///
@@ -74,6 +92,7 @@ public class MetadataController(IUnitOfWork unitOfWork, ILocalizationService loc
{
return Ok(await unitOfWork.PersonRepository.GetAllPeopleDtosForLibrariesAsync(User.GetUserId(), ids));
}
+
return Ok(await unitOfWork.PersonRepository.GetAllPeopleDtosForLibrariesAsync(User.GetUserId()));
}
@@ -94,6 +113,22 @@ public class MetadataController(IUnitOfWork unitOfWork, ILocalizationService loc
return Ok(await unitOfWork.TagRepository.GetAllTagDtosForLibrariesAsync(User.GetUserId()));
}
+ ///
+ /// Returns a list of Tags with counts for counts when Tag is on Series/Chapter
+ ///
+ ///
+ [HttpPost("tags-with-counts")]
+ [ResponseCache(CacheProfileName = ResponseCacheProfiles.FiveMinute)]
+ public async Task>> GetBrowseTags(UserParams? userParams = null)
+ {
+ userParams ??= UserParams.Default;
+
+ var list = await unitOfWork.TagRepository.GetBrowseableTag(User.GetUserId(), userParams);
+ Response.AddPaginationHeader(list.CurrentPage, list.PageSize, list.TotalCount, list.TotalPages);
+
+ return Ok(list);
+ }
+
///
/// Fetches all age ratings from the instance
///
diff --git a/API/Controllers/OPDSController.cs b/API/Controllers/OPDSController.cs
index fcc4ca58f..6e96c3063 100644
--- a/API/Controllers/OPDSController.cs
+++ b/API/Controllers/OPDSController.cs
@@ -15,6 +15,7 @@ using API.DTOs.CollectionTags;
using API.DTOs.Filtering;
using API.DTOs.Filtering.v2;
using API.DTOs.OPDS;
+using API.DTOs.Person;
using API.DTOs.Progress;
using API.DTOs.Search;
using API.Entities;
diff --git a/API/Controllers/PersonController.cs b/API/Controllers/PersonController.cs
index 1094a1137..7328ff954 100644
--- a/API/Controllers/PersonController.cs
+++ b/API/Controllers/PersonController.cs
@@ -1,7 +1,13 @@
using System.Collections.Generic;
+using System.Linq;
using System.Threading.Tasks;
using API.Data;
+using API.Data.Repositories;
using API.DTOs;
+using API.DTOs.Filtering.v2;
+using API.DTOs.Metadata.Browse;
+using API.DTOs.Metadata.Browse.Requests;
+using API.DTOs.Person;
using API.Entities.Enums;
using API.Extensions;
using API.Helpers;
@@ -24,9 +30,10 @@ public class PersonController : BaseApiController
private readonly ICoverDbService _coverDbService;
private readonly IImageService _imageService;
private readonly IEventHub _eventHub;
+ private readonly IPersonService _personService;
public PersonController(IUnitOfWork unitOfWork, ILocalizationService localizationService, IMapper mapper,
- ICoverDbService coverDbService, IImageService imageService, IEventHub eventHub)
+ ICoverDbService coverDbService, IImageService imageService, IEventHub eventHub, IPersonService personService)
{
_unitOfWork = unitOfWork;
_localizationService = localizationService;
@@ -34,6 +41,7 @@ public class PersonController : BaseApiController
_coverDbService = coverDbService;
_imageService = imageService;
_eventHub = eventHub;
+ _personService = personService;
}
@@ -43,6 +51,17 @@ public class PersonController : BaseApiController
return Ok(await _unitOfWork.PersonRepository.GetPersonDtoByName(name, User.GetUserId()));
}
+ ///
+ /// Find a person by name or alias against a query string
+ ///
+ ///
+ ///
+ [HttpGet("search")]
+ public async Task>> SearchPeople([FromQuery] string queryString)
+ {
+ return Ok(await _unitOfWork.PersonRepository.SearchPeople(queryString));
+ }
+
///
/// Returns all roles for a Person
///
@@ -54,17 +73,20 @@ public class PersonController : BaseApiController
return Ok(await _unitOfWork.PersonRepository.GetRolesForPersonByName(personId, User.GetUserId()));
}
+
///
/// Returns a list of authors and artists for browsing
///
///
///
[HttpPost("all")]
- public async Task>> GetAuthorsForBrowse([FromQuery] UserParams? userParams)
+ public async Task>> GetPeopleForBrowse(BrowsePersonFilterDto filter, [FromQuery] UserParams? userParams)
{
userParams ??= UserParams.Default;
- var list = await _unitOfWork.PersonRepository.GetAllWritersAndSeriesCount(User.GetUserId(), userParams);
+
+ var list = await _unitOfWork.PersonRepository.GetBrowsePersonDtos(User.GetUserId(), filter, userParams);
Response.AddPaginationHeader(list.CurrentPage, list.PageSize, list.TotalCount, list.TotalPages);
+
return Ok(list);
}
@@ -78,7 +100,7 @@ public class PersonController : BaseApiController
public async Task> UpdatePerson(UpdatePersonDto dto)
{
// This needs to get all people and update them equally
- var person = await _unitOfWork.PersonRepository.GetPersonById(dto.Id);
+ var person = await _unitOfWork.PersonRepository.GetPersonById(dto.Id, PersonIncludes.Aliases);
if (person == null) return BadRequest(_localizationService.Translate(User.GetUserId(), "person-doesnt-exist"));
if (string.IsNullOrEmpty(dto.Name)) return BadRequest(await _localizationService.Translate(User.GetUserId(), "person-name-required"));
@@ -90,7 +112,12 @@ public class PersonController : BaseApiController
return BadRequest(await _localizationService.Translate(User.GetUserId(), "person-name-unique"));
}
+ var success = await _personService.UpdatePersonAliasesAsync(person, dto.Aliases);
+ if (!success) return BadRequest(await _localizationService.Translate(User.GetUserId(), "aliases-have-overlap"));
+
+
person.Name = dto.Name?.Trim();
+ person.NormalizedName = person.Name.ToNormalized();
person.Description = dto.Description ?? string.Empty;
person.CoverImageLocked = dto.CoverImageLocked;
@@ -158,7 +185,7 @@ public class PersonController : BaseApiController
[HttpGet("series-known-for")]
public async Task>> GetKnownSeries(int personId)
{
- return Ok(await _unitOfWork.PersonRepository.GetSeriesKnownFor(personId));
+ return Ok(await _unitOfWork.PersonRepository.GetSeriesKnownFor(personId, User.GetUserId()));
}
///
@@ -173,5 +200,42 @@ public class PersonController : BaseApiController
return Ok(await _unitOfWork.PersonRepository.GetChaptersForPersonByRole(personId, User.GetUserId(), role));
}
+ ///
+ /// Merges Persons into one, this action is irreversible
+ ///
+ ///
+ ///
+ [HttpPost("merge")]
+ [Authorize("RequireAdminRole")]
+ public async Task> MergePeople(PersonMergeDto dto)
+ {
+ var dst = await _unitOfWork.PersonRepository.GetPersonById(dto.DestId, PersonIncludes.All);
+ if (dst == null) return BadRequest();
+
+ var src = await _unitOfWork.PersonRepository.GetPersonById(dto.SrcId, PersonIncludes.All);
+ if (src == null) return BadRequest();
+
+ await _personService.MergePeopleAsync(src, dst);
+ await _eventHub.SendMessageAsync(MessageFactory.PersonMerged, MessageFactory.PersonMergedMessage(dst, src));
+
+ return Ok(_mapper.Map(dst));
+ }
+
+ ///
+ /// Ensure the alias is valid to be added. For example, the alias cannot be on another person or be the same as the current person name/alias.
+ ///
+ ///
+ ///
+ ///
+ [HttpGet("valid-alias")]
+ public async Task> IsValidAlias(int personId, string alias)
+ {
+ var person = await _unitOfWork.PersonRepository.GetPersonById(personId, PersonIncludes.Aliases);
+ if (person == null) return NotFound();
+
+ var existingAlias = await _unitOfWork.PersonRepository.AnyAliasExist(alias);
+ return Ok(!existingAlias && person.NormalizedName != alias.ToNormalized());
+ }
+
}
diff --git a/API/Controllers/PluginController.cs b/API/Controllers/PluginController.cs
index c7f48cf54..f39462bbf 100644
--- a/API/Controllers/PluginController.cs
+++ b/API/Controllers/PluginController.cs
@@ -45,7 +45,7 @@ public class PluginController(IUnitOfWork unitOfWork, ITokenService tokenService
throw new KavitaUnauthenticatedUserException();
}
var user = await unitOfWork.UserRepository.GetUserByIdAsync(userId);
- logger.LogInformation("Plugin {PluginName} has authenticated with {UserName} ({UserId})'s API Key", pluginName.Replace(Environment.NewLine, string.Empty), user!.UserName, userId);
+ logger.LogInformation("Plugin {PluginName} has authenticated with {UserName} ({AppUserId})'s API Key", pluginName.Replace(Environment.NewLine, string.Empty), user!.UserName, userId);
return new UserDto
{
diff --git a/API/Controllers/ReadingListController.cs b/API/Controllers/ReadingListController.cs
index 6c9be6c75..1187992bc 100644
--- a/API/Controllers/ReadingListController.cs
+++ b/API/Controllers/ReadingListController.cs
@@ -4,7 +4,7 @@ using System.Threading.Tasks;
using API.Constants;
using API.Data;
using API.Data.Repositories;
-using API.DTOs;
+using API.DTOs.Person;
using API.DTOs.ReadingLists;
using API.Entities.Enums;
using API.Extensions;
diff --git a/API/Controllers/ReadingProfileController.cs b/API/Controllers/ReadingProfileController.cs
new file mode 100644
index 000000000..bc1b4fa52
--- /dev/null
+++ b/API/Controllers/ReadingProfileController.cs
@@ -0,0 +1,198 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using API.Data;
+using API.Data.Repositories;
+using API.DTOs;
+using API.Extensions;
+using API.Services;
+using AutoMapper;
+using Kavita.Common;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+
+namespace API.Controllers;
+
+[Route("api/reading-profile")]
+public class ReadingProfileController(ILogger logger, IUnitOfWork unitOfWork,
+ IReadingProfileService readingProfileService): BaseApiController
+{
+
+ ///
+ /// Gets all non-implicit reading profiles for a user
+ ///
+ ///
+ [HttpGet("all")]
+ public async Task>> GetAllReadingProfiles()
+ {
+ return Ok(await unitOfWork.AppUserReadingProfileRepository.GetProfilesDtoForUser(User.GetUserId(), true));
+ }
+
+ ///
+ /// Returns the ReadingProfile that should be applied to the given series, walks up the tree.
+ /// Series -> Library -> Default
+ ///
+ ///
+ ///
+ ///
+ [HttpGet("{seriesId:int}")]
+ public async Task> GetProfileForSeries(int seriesId, [FromQuery] bool skipImplicit)
+ {
+ return Ok(await readingProfileService.GetReadingProfileDtoForSeries(User.GetUserId(), seriesId, skipImplicit));
+ }
+
+ ///
+ /// Returns the (potential) Reading Profile bound to the library
+ ///
+ ///
+ ///
+ [HttpGet("library")]
+ public async Task> GetProfileForLibrary(int libraryId)
+ {
+ return Ok(await readingProfileService.GetReadingProfileDtoForLibrary(User.GetUserId(), libraryId));
+ }
+
+ ///
+ /// Creates a new reading profile for the current user
+ ///
+ ///
+ ///
+ [HttpPost("create")]
+ public async Task> CreateReadingProfile([FromBody] UserReadingProfileDto dto)
+ {
+ return Ok(await readingProfileService.CreateReadingProfile(User.GetUserId(), dto));
+ }
+
+ ///
+ /// Promotes the implicit profile to a user profile. Removes the series from other profiles
+ ///
+ ///
+ ///
+ [HttpPost("promote")]
+ public async Task> PromoteImplicitReadingProfile([FromQuery] int profileId)
+ {
+ return Ok(await readingProfileService.PromoteImplicitProfile(User.GetUserId(), profileId));
+ }
+
+ ///
+ /// Update the implicit reading profile for a series, creates one if none exists
+ ///
+ /// Any modification to the reader settings during reading will create an implicit profile. Use "update-parent" to save to the bound series profile.
+ ///
+ ///
+ ///
+ [HttpPost("series")]
+ public async Task> UpdateReadingProfileForSeries([FromBody] UserReadingProfileDto dto, [FromQuery] int seriesId)
+ {
+ var updatedProfile = await readingProfileService.UpdateImplicitReadingProfile(User.GetUserId(), seriesId, dto);
+ return Ok(updatedProfile);
+ }
+
+ ///
+ /// Updates the non-implicit reading profile for the given series, and removes implicit profiles
+ ///
+ ///
+ ///
+ ///
+ [HttpPost("update-parent")]
+ public async Task> UpdateParentProfileForSeries([FromBody] UserReadingProfileDto dto, [FromQuery] int seriesId)
+ {
+ var newParentProfile = await readingProfileService.UpdateParent(User.GetUserId(), seriesId, dto);
+ return Ok(newParentProfile);
+ }
+
+ ///
+ /// Updates the given reading profile, must belong to the current user
+ ///
+ ///
+ /// The updated reading profile
+ ///
+ /// This does not update connected series and libraries.
+ ///
+ [HttpPost]
+ public async Task> UpdateReadingProfile(UserReadingProfileDto dto)
+ {
+ return Ok(await readingProfileService.UpdateReadingProfile(User.GetUserId(), dto));
+ }
+
+ ///
+ /// Deletes the given profile, requires the profile to belong to the logged-in user
+ ///
+ ///
+ ///
+ ///
+ ///
+ [HttpDelete]
+ public async Task DeleteReadingProfile([FromQuery] int profileId)
+ {
+ await readingProfileService.DeleteReadingProfile(User.GetUserId(), profileId);
+ return Ok();
+ }
+
+ ///
+ /// Sets the reading profile for a given series, removes the old one
+ ///
+ ///
+ ///
+ ///
+ [HttpPost("series/{seriesId:int}")]
+ public async Task AddProfileToSeries(int seriesId, [FromQuery] int profileId)
+ {
+ await readingProfileService.AddProfileToSeries(User.GetUserId(), profileId, seriesId);
+ return Ok();
+ }
+
+ ///
+ /// Clears the reading profile for the given series for the currently logged-in user
+ ///
+ ///
+ ///
+ [HttpDelete("series/{seriesId:int}")]
+ public async Task ClearSeriesProfile(int seriesId)
+ {
+ await readingProfileService.ClearSeriesProfile(User.GetUserId(), seriesId);
+ return Ok();
+ }
+
+ ///
+ /// Sets the reading profile for a given library, removes the old one
+ ///
+ ///
+ ///
+ ///
+ [HttpPost("library/{libraryId:int}")]
+ public async Task AddProfileToLibrary(int libraryId, [FromQuery] int profileId)
+ {
+ await readingProfileService.AddProfileToLibrary(User.GetUserId(), profileId, libraryId);
+ return Ok();
+ }
+
+ ///
+ /// Clears the reading profile for the given library for the currently logged-in user
+ ///
+ ///
+ ///
+ ///
+ [HttpDelete("library/{libraryId:int}")]
+ public async Task ClearLibraryProfile(int libraryId)
+ {
+ await readingProfileService.ClearLibraryProfile(User.GetUserId(), libraryId);
+ return Ok();
+ }
+
+ ///
+ /// Assigns the reading profile to all passes series, and deletes their implicit profiles
+ ///
+ ///
+ ///
+ ///
+ [HttpPost("bulk")]
+ public async Task BulkAddReadingProfile([FromQuery] int profileId, [FromBody] IList seriesIds)
+ {
+ await readingProfileService.BulkAddProfileToSeries(User.GetUserId(), profileId, seriesIds);
+ return Ok();
+ }
+
+}
diff --git a/API/Controllers/ScrobblingController.cs b/API/Controllers/ScrobblingController.cs
index 3904cb8e0..986f4f8e7 100644
--- a/API/Controllers/ScrobblingController.cs
+++ b/API/Controllers/ScrobblingController.cs
@@ -254,7 +254,7 @@ public class ScrobblingController : BaseApiController
}
///
- /// Adds a hold against the Series for user's scrobbling
+ /// Remove a hold against the Series for user's scrobbling
///
///
///
@@ -281,4 +281,18 @@ public class ScrobblingController : BaseApiController
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(User.GetUserId());
return Ok(user is {HasRunScrobbleEventGeneration: true});
}
+
+ ///
+ /// Delete the given scrobble events if they belong to that user
+ ///
+ ///
+ ///
+ [HttpPost("bulk-remove-events")]
+ public async Task BulkRemoveScrobbleEvents(IList eventIds)
+ {
+ var events = await _unitOfWork.ScrobbleRepository.GetUserEvents(User.GetUserId(), eventIds);
+ _unitOfWork.ScrobbleRepository.Remove(events);
+ await _unitOfWork.CommitAsync();
+ return Ok();
+ }
}
diff --git a/API/Controllers/SearchController.cs b/API/Controllers/SearchController.cs
index 5aa54d1db..cc89a124e 100644
--- a/API/Controllers/SearchController.cs
+++ b/API/Controllers/SearchController.cs
@@ -63,6 +63,7 @@ public class SearchController : BaseApiController
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync(User.GetUsername());
if (user == null) return Unauthorized();
+
var libraries = _unitOfWork.LibraryRepository.GetLibraryIdsForUserIdAsync(user.Id, QueryContext.Search).ToList();
if (libraries.Count == 0) return BadRequest(await _localizationService.Translate(User.GetUserId(), "libraries-restricted"));
diff --git a/API/Controllers/SeriesController.cs b/API/Controllers/SeriesController.cs
index 7cd897c32..389ff33a7 100644
--- a/API/Controllers/SeriesController.cs
+++ b/API/Controllers/SeriesController.cs
@@ -14,6 +14,7 @@ using API.DTOs.Recommendation;
using API.DTOs.SeriesDetail;
using API.Entities;
using API.Entities.Enums;
+using API.Entities.MetadataMatching;
using API.Extensions;
using API.Helpers;
using API.Services;
@@ -224,6 +225,7 @@ public class SeriesController : BaseApiController
needsRefreshMetadata = true;
series.CoverImage = null;
series.CoverImageLocked = false;
+ series.Metadata.KPlusOverrides.Remove(MetadataSettingField.Covers);
_logger.LogDebug("[SeriesCoverImageBug] Setting Series Cover Image to null: {SeriesId}", series.Id);
series.ResetColorScape();
@@ -310,7 +312,7 @@ public class SeriesController : BaseApiController
///
///
///
- ///
+ /// This is not in use
///
[HttpPost("all-v2")]
public async Task>> GetAllSeriesV2(FilterV2Dto filterDto, [FromQuery] UserParams userParams,
@@ -321,8 +323,6 @@ public class SeriesController : BaseApiController
await _unitOfWork.SeriesRepository.GetSeriesDtoForLibraryIdV2Async(userId, userParams, filterDto, context);
// Apply progress/rating information (I can't work out how to do this in initial query)
- if (series == null) return BadRequest(await _localizationService.Translate(User.GetUserId(), "no-series"));
-
await _unitOfWork.SeriesRepository.AddSeriesModifiers(userId, series);
Response.AddPaginationHeader(series.CurrentPage, series.PageSize, series.TotalCount, series.TotalPages);
diff --git a/API/Controllers/UploadController.cs b/API/Controllers/UploadController.cs
index 4b935a1bf..9652ba494 100644
--- a/API/Controllers/UploadController.cs
+++ b/API/Controllers/UploadController.cs
@@ -6,6 +6,7 @@ using API.Data;
using API.Data.Repositories;
using API.DTOs.Uploads;
using API.Entities.Enums;
+using API.Entities.MetadataMatching;
using API.Extensions;
using API.Services;
using API.Services.Tasks.Metadata;
@@ -112,8 +113,10 @@ public class UploadController : BaseApiController
series.CoverImage = filePath;
series.CoverImageLocked = lockState;
+ series.Metadata.KPlusOverrides.Remove(MetadataSettingField.Covers);
_imageService.UpdateColorScape(series);
_unitOfWork.SeriesRepository.Update(series);
+ _unitOfWork.SeriesRepository.Update(series.Metadata);
if (_unitOfWork.HasChanges())
{
@@ -277,6 +280,7 @@ public class UploadController : BaseApiController
chapter.CoverImage = filePath;
chapter.CoverImageLocked = lockState;
+ chapter.KPlusOverrides.Remove(MetadataSettingField.ChapterCovers);
_unitOfWork.ChapterRepository.Update(chapter);
var volume = await _unitOfWork.VolumeRepository.GetVolumeAsync(chapter.VolumeId);
if (volume != null)
diff --git a/API/Controllers/UsersController.cs b/API/Controllers/UsersController.cs
index 944ea987b..17ebc758e 100644
--- a/API/Controllers/UsersController.cs
+++ b/API/Controllers/UsersController.cs
@@ -103,38 +103,13 @@ public class UsersController : BaseApiController
var existingPreferences = user!.UserPreferences;
- existingPreferences.ReadingDirection = preferencesDto.ReadingDirection;
- existingPreferences.ScalingOption = preferencesDto.ScalingOption;
- existingPreferences.PageSplitOption = preferencesDto.PageSplitOption;
- existingPreferences.AutoCloseMenu = preferencesDto.AutoCloseMenu;
- existingPreferences.ShowScreenHints = preferencesDto.ShowScreenHints;
- existingPreferences.EmulateBook = preferencesDto.EmulateBook;
- existingPreferences.ReaderMode = preferencesDto.ReaderMode;
- existingPreferences.LayoutMode = preferencesDto.LayoutMode;
- existingPreferences.BackgroundColor = string.IsNullOrEmpty(preferencesDto.BackgroundColor) ? "#000000" : preferencesDto.BackgroundColor;
- existingPreferences.BookReaderMargin = preferencesDto.BookReaderMargin;
- existingPreferences.BookReaderLineSpacing = preferencesDto.BookReaderLineSpacing;
- existingPreferences.BookReaderFontFamily = preferencesDto.BookReaderFontFamily;
- existingPreferences.BookReaderFontSize = preferencesDto.BookReaderFontSize;
- existingPreferences.BookReaderTapToPaginate = preferencesDto.BookReaderTapToPaginate;
- existingPreferences.BookReaderReadingDirection = preferencesDto.BookReaderReadingDirection;
- existingPreferences.BookReaderWritingStyle = preferencesDto.BookReaderWritingStyle;
- existingPreferences.BookThemeName = preferencesDto.BookReaderThemeName;
- existingPreferences.BookReaderLayoutMode = preferencesDto.BookReaderLayoutMode;
- existingPreferences.BookReaderImmersiveMode = preferencesDto.BookReaderImmersiveMode;
existingPreferences.GlobalPageLayoutMode = preferencesDto.GlobalPageLayoutMode;
existingPreferences.BlurUnreadSummaries = preferencesDto.BlurUnreadSummaries;
- existingPreferences.LayoutMode = preferencesDto.LayoutMode;
existingPreferences.PromptForDownloadSize = preferencesDto.PromptForDownloadSize;
existingPreferences.NoTransitions = preferencesDto.NoTransitions;
- existingPreferences.SwipeToPaginate = preferencesDto.SwipeToPaginate;
existingPreferences.CollapseSeriesRelationships = preferencesDto.CollapseSeriesRelationships;
existingPreferences.ShareReviews = preferencesDto.ShareReviews;
- existingPreferences.PdfTheme = preferencesDto.PdfTheme;
- existingPreferences.PdfScrollMode = preferencesDto.PdfScrollMode;
- existingPreferences.PdfSpreadMode = preferencesDto.PdfSpreadMode;
-
if (await _licenseService.HasActiveLicense())
{
existingPreferences.AniListScrobblingEnabled = preferencesDto.AniListScrobblingEnabled;
diff --git a/API/DTOs/Account/AgeRestrictionDto.cs b/API/DTOs/Account/AgeRestrictionDto.cs
index 0aaec9b97..6505bdbff 100644
--- a/API/DTOs/Account/AgeRestrictionDto.cs
+++ b/API/DTOs/Account/AgeRestrictionDto.cs
@@ -2,15 +2,15 @@
namespace API.DTOs.Account;
-public class AgeRestrictionDto
+public sealed record AgeRestrictionDto
{
///
/// The maximum age rating a user has access to. -1 if not applicable
///
- public required AgeRating AgeRating { get; set; } = AgeRating.NotApplicable;
+ public required AgeRating AgeRating { get; init; } = AgeRating.NotApplicable;
///
/// Are Unknowns explicitly allowed against age rating
///
/// Unknown is always lowest and default age rating. Setting this to false will ensure Teen age rating applies and unknowns are still filtered
- public required bool IncludeUnknowns { get; set; } = false;
+ public required bool IncludeUnknowns { get; init; } = false;
}
diff --git a/API/DTOs/Account/ConfirmEmailDto.cs b/API/DTOs/Account/ConfirmEmailDto.cs
index 2f5849e74..413f9f34a 100644
--- a/API/DTOs/Account/ConfirmEmailDto.cs
+++ b/API/DTOs/Account/ConfirmEmailDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Account;
-public class ConfirmEmailDto
+public sealed record ConfirmEmailDto
{
[Required]
public string Email { get; set; } = default!;
diff --git a/API/DTOs/Account/ConfirmEmailUpdateDto.cs b/API/DTOs/Account/ConfirmEmailUpdateDto.cs
index 42abb1295..2a0738e35 100644
--- a/API/DTOs/Account/ConfirmEmailUpdateDto.cs
+++ b/API/DTOs/Account/ConfirmEmailUpdateDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Account;
-public class ConfirmEmailUpdateDto
+public sealed record ConfirmEmailUpdateDto
{
[Required]
public string Email { get; set; } = default!;
diff --git a/API/DTOs/Account/ConfirmMigrationEmailDto.cs b/API/DTOs/Account/ConfirmMigrationEmailDto.cs
index efb42b8fd..cdfc1505c 100644
--- a/API/DTOs/Account/ConfirmMigrationEmailDto.cs
+++ b/API/DTOs/Account/ConfirmMigrationEmailDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Account;
-public class ConfirmMigrationEmailDto
+public sealed record ConfirmMigrationEmailDto
{
public string Email { get; set; } = default!;
public string Token { get; set; } = default!;
diff --git a/API/DTOs/Account/ConfirmPasswordResetDto.cs b/API/DTOs/Account/ConfirmPasswordResetDto.cs
index 16dd86f9a..00aff301b 100644
--- a/API/DTOs/Account/ConfirmPasswordResetDto.cs
+++ b/API/DTOs/Account/ConfirmPasswordResetDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Account;
-public class ConfirmPasswordResetDto
+public sealed record ConfirmPasswordResetDto
{
[Required]
public string Email { get; set; } = default!;
diff --git a/API/DTOs/Account/InviteUserDto.cs b/API/DTOs/Account/InviteUserDto.cs
index 112013053..c12bebc2b 100644
--- a/API/DTOs/Account/InviteUserDto.cs
+++ b/API/DTOs/Account/InviteUserDto.cs
@@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations;
namespace API.DTOs.Account;
-public class InviteUserDto
+public sealed record InviteUserDto
{
[Required]
public string Email { get; set; } = default!;
diff --git a/API/DTOs/Account/InviteUserResponse.cs b/API/DTOs/Account/InviteUserResponse.cs
index a7e0d86ea..ed16bd05e 100644
--- a/API/DTOs/Account/InviteUserResponse.cs
+++ b/API/DTOs/Account/InviteUserResponse.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Account;
-public class InviteUserResponse
+public sealed record InviteUserResponse
{
///
/// Email link used to setup the user account
diff --git a/API/DTOs/Account/LoginDto.cs b/API/DTOs/Account/LoginDto.cs
index fe8fce088..97338640b 100644
--- a/API/DTOs/Account/LoginDto.cs
+++ b/API/DTOs/Account/LoginDto.cs
@@ -1,7 +1,7 @@
namespace API.DTOs.Account;
#nullable enable
-public class LoginDto
+public sealed record LoginDto
{
public string Username { get; init; } = default!;
public string Password { get; set; } = default!;
diff --git a/API/DTOs/Account/MigrateUserEmailDto.cs b/API/DTOs/Account/MigrateUserEmailDto.cs
index 60d042165..4630c510f 100644
--- a/API/DTOs/Account/MigrateUserEmailDto.cs
+++ b/API/DTOs/Account/MigrateUserEmailDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Account;
-public class MigrateUserEmailDto
+public sealed record MigrateUserEmailDto
{
public string Email { get; set; } = default!;
public string Username { get; set; } = default!;
diff --git a/API/DTOs/Account/ResetPasswordDto.cs b/API/DTOs/Account/ResetPasswordDto.cs
index 51a195131..545ca5ba6 100644
--- a/API/DTOs/Account/ResetPasswordDto.cs
+++ b/API/DTOs/Account/ResetPasswordDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Account;
-public class ResetPasswordDto
+public sealed record ResetPasswordDto
{
///
/// The Username of the User
diff --git a/API/DTOs/Account/TokenRequestDto.cs b/API/DTOs/Account/TokenRequestDto.cs
index 85ab9f87a..5c798721c 100644
--- a/API/DTOs/Account/TokenRequestDto.cs
+++ b/API/DTOs/Account/TokenRequestDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Account;
-public class TokenRequestDto
+public sealed record TokenRequestDto
{
public string Token { get; init; } = default!;
public string RefreshToken { get; init; } = default!;
diff --git a/API/DTOs/Account/UpdateAgeRestrictionDto.cs b/API/DTOs/Account/UpdateAgeRestrictionDto.cs
index ef6be1bba..2fa9c89d2 100644
--- a/API/DTOs/Account/UpdateAgeRestrictionDto.cs
+++ b/API/DTOs/Account/UpdateAgeRestrictionDto.cs
@@ -3,7 +3,7 @@ using API.Entities.Enums;
namespace API.DTOs.Account;
-public class UpdateAgeRestrictionDto
+public sealed record UpdateAgeRestrictionDto
{
[Required]
public AgeRating AgeRating { get; set; }
diff --git a/API/DTOs/Account/UpdateEmailDto.cs b/API/DTOs/Account/UpdateEmailDto.cs
index eac06be53..873862ba1 100644
--- a/API/DTOs/Account/UpdateEmailDto.cs
+++ b/API/DTOs/Account/UpdateEmailDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Account;
-public class UpdateEmailDto
+public sealed record UpdateEmailDto
{
public string Email { get; set; } = default!;
public string Password { get; set; } = default!;
diff --git a/API/DTOs/Account/UpdateUserDto.cs b/API/DTOs/Account/UpdateUserDto.cs
index c40124b7b..0cb0eaf66 100644
--- a/API/DTOs/Account/UpdateUserDto.cs
+++ b/API/DTOs/Account/UpdateUserDto.cs
@@ -4,12 +4,16 @@ using System.ComponentModel.DataAnnotations;
namespace API.DTOs.Account;
#nullable enable
-public record UpdateUserDto
+public sealed record UpdateUserDto
{
+ ///
public int UserId { get; set; }
+ ///
public string Username { get; set; } = default!;
+ ///
/// List of Roles to assign to user. If admin not present, Pleb will be applied.
/// If admin present, all libraries will be granted access and will ignore those from DTO.
+ ///
public IList Roles { get; init; } = default!;
///
/// A list of libraries to grant access to
@@ -19,8 +23,6 @@ public record UpdateUserDto
/// An Age Rating which will limit the account to seeing everything equal to or below said rating.
///
public AgeRestrictionDto AgeRestriction { get; init; } = default!;
- ///
- /// Email of the user
- ///
+ ///
public string? Email { get; set; } = default!;
}
diff --git a/API/DTOs/BulkActionDto.cs b/API/DTOs/BulkActionDto.cs
index d3ce75293..c26a73e9c 100644
--- a/API/DTOs/BulkActionDto.cs
+++ b/API/DTOs/BulkActionDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs;
-public class BulkActionDto
+public sealed record BulkActionDto
{
public List Ids { get; set; }
/**
diff --git a/API/DTOs/ChapterDetailPlusDto.cs b/API/DTOs/ChapterDetailPlusDto.cs
index 9f9cfb8ab..d99482e55 100644
--- a/API/DTOs/ChapterDetailPlusDto.cs
+++ b/API/DTOs/ChapterDetailPlusDto.cs
@@ -4,7 +4,7 @@ using API.DTOs.SeriesDetail;
namespace API.DTOs;
-public class ChapterDetailPlusDto
+public sealed record ChapterDetailPlusDto
{
public float Rating { get; set; }
public bool HasBeenRated { get; set; }
diff --git a/API/DTOs/ChapterDto.cs b/API/DTOs/ChapterDto.cs
index 70c77e92d..85624b51c 100644
--- a/API/DTOs/ChapterDto.cs
+++ b/API/DTOs/ChapterDto.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using API.DTOs.Metadata;
+using API.DTOs.Person;
using API.Entities.Enums;
using API.Entities.Interfaces;
@@ -13,37 +14,24 @@ namespace API.DTOs;
///
public class ChapterDto : IHasReadTimeEstimate, IHasCoverImage
{
+ ///
public int Id { get; init; }
- ///
- /// Range of chapters. Chapter 2-4 -> "2-4". Chapter 2 -> "2". If special, will be special name.
- ///
- /// This can be something like 19.HU or Alpha as some comics are like this
+ ///
public string Range { get; init; } = default!;
- ///
- /// Smallest number of the Range.
- ///
+ ///
[Obsolete("Use MinNumber and MaxNumber instead")]
public string Number { get; init; } = default!;
- ///
- /// This may be 0 under the circumstance that the Issue is "Alpha" or other non-standard numbers.
- ///
+ ///
public float MinNumber { get; init; }
+ ///
public float MaxNumber { get; init; }
- ///
- /// The sorting order of the Chapter. Inherits from MinNumber, but can be overridden.
- ///
+ ///
public float SortOrder { get; set; }
- ///
- /// Total number of pages in all MangaFiles
- ///
+ ///
public int Pages { get; init; }
- ///
- /// If this Chapter contains files that could only be identified as Series or has Special Identifier from filename
- ///
+ ///
public bool IsSpecial { get; init; }
- ///
- /// Used for books/specials to display custom title. For non-specials/books, will be set to
- ///
+ ///
public string Title { get; set; } = default!;
///
/// The files that represent this Chapter
@@ -61,46 +49,25 @@ public class ChapterDto : IHasReadTimeEstimate, IHasCoverImage
/// The last time a chapter was read by current authenticated user
///
public DateTime LastReadingProgress { get; set; }
- ///
- /// If the Cover Image is locked for this entity
- ///
+ ///
public bool CoverImageLocked { get; set; }
- ///
- /// Volume Id this Chapter belongs to
- ///
+ ///
public int VolumeId { get; init; }
- ///
- /// When chapter was created
- ///
+ ///
public DateTime CreatedUtc { get; set; }
+ ///
public DateTime LastModifiedUtc { get; set; }
- ///
- /// When chapter was created in local server time
- ///
- /// This is required for Tachiyomi Extension
+ ///
public DateTime Created { get; set; }
- ///
- /// When the chapter was released.
- ///
- /// Metadata field
+ ///
public DateTime ReleaseDate { get; init; }
- ///
- /// Title of the Chapter/Issue
- ///
- /// Metadata field
+ ///
public string TitleName { get; set; } = default!;
- ///
- /// Summary of the Chapter
- ///
- /// This is not set normally, only for Series Detail
+ ///
public string Summary { get; init; } = default!;
- ///
- /// Age Rating for the issue/chapter
- ///
+ ///
public AgeRating AgeRating { get; init; }
- ///
- /// Total words in a Chapter (books only)
- ///
+ ///
public long WordCount { get; set; } = 0L;
///
/// Formatted Volume title ie) Volume 2.
@@ -113,14 +80,9 @@ public class ChapterDto : IHasReadTimeEstimate, IHasCoverImage
public int MaxHoursToRead { get; set; }
///
public float AvgHoursToRead { get; set; }
- ///
- /// Comma-separated link of urls to external services that have some relation to the Chapter
- ///
+ ///
public string WebLinks { get; set; }
- ///
- /// ISBN-13 (usually) of the Chapter
- ///
- /// This is guaranteed to be Valid
+ ///
public string ISBN { get; set; }
#region Metadata
@@ -146,51 +108,60 @@ public class ChapterDto : IHasReadTimeEstimate, IHasCoverImage
///
public ICollection Tags { get; set; } = new List();
public PublicationStatus PublicationStatus { get; set; }
- ///
- /// Language for the Chapter/Issue
- ///
+ ///
public string? Language { get; set; }
- ///
- /// Number in the TotalCount of issues
- ///
+ ///
public int Count { get; set; }
- ///
- /// Total number of issues for the series
- ///
+ ///
public int TotalCount { get; set; }
+ ///
public bool LanguageLocked { get; set; }
+ ///
public bool SummaryLocked { get; set; }
- ///
- /// Locked by user so metadata updates from scan loop will not override AgeRating
- ///
+ ///
public bool AgeRatingLocked { get; set; }
- ///
- /// Locked by user so metadata updates from scan loop will not override PublicationStatus
- ///
public bool PublicationStatusLocked { get; set; }
+ ///
public bool GenresLocked { get; set; }
+ ///
public bool TagsLocked { get; set; }
+ ///
public bool WriterLocked { get; set; }
+ ///
public bool CharacterLocked { get; set; }
+ ///
public bool ColoristLocked { get; set; }
+ ///
public bool EditorLocked { get; set; }
+ ///
public bool InkerLocked { get; set; }
+ ///
public bool ImprintLocked { get; set; }
+ ///
public bool LettererLocked { get; set; }
+ ///
public bool PencillerLocked { get; set; }
+ ///
public bool PublisherLocked { get; set; }
+ ///
public bool TranslatorLocked { get; set; }
+ ///
public bool TeamLocked { get; set; }
+ ///
public bool LocationLocked { get; set; }
+ ///
public bool CoverArtistLocked { get; set; }
public bool ReleaseYearLocked { get; set; }
#endregion
- public string CoverImage { get; set; }
- public string PrimaryColor { get; set; } = string.Empty;
- public string SecondaryColor { get; set; } = string.Empty;
+ ///
+ public string? CoverImage { get; set; }
+ ///
+ public string? PrimaryColor { get; set; } = string.Empty;
+ ///
+ public string? SecondaryColor { get; set; } = string.Empty;
public void ResetColorScape()
{
diff --git a/API/DTOs/Collection/AppUserCollectionDto.cs b/API/DTOs/Collection/AppUserCollectionDto.cs
index ecfb5c062..0634b5d83 100644
--- a/API/DTOs/Collection/AppUserCollectionDto.cs
+++ b/API/DTOs/Collection/AppUserCollectionDto.cs
@@ -6,52 +6,52 @@ using API.Services.Plus;
namespace API.DTOs.Collection;
#nullable enable
-public class AppUserCollectionDto : IHasCoverImage
+public sealed record AppUserCollectionDto : IHasCoverImage
{
public int Id { get; init; }
- public string Title { get; set; } = default!;
- public string? Summary { get; set; } = default!;
- public bool Promoted { get; set; }
- public AgeRating AgeRating { get; set; }
+ public string Title { get; init; } = default!;
+ public string? Summary { get; init; } = default!;
+ public bool Promoted { get; init; }
+ public AgeRating AgeRating { get; init; }
///
/// This is used to tell the UI if it should request a Cover Image or not. If null or empty, it has not been set.
///
public string? CoverImage { get; set; } = string.Empty;
- public string PrimaryColor { get; set; } = string.Empty;
- public string SecondaryColor { get; set; } = string.Empty;
- public bool CoverImageLocked { get; set; }
+ public string? PrimaryColor { get; set; } = string.Empty;
+ public string? SecondaryColor { get; set; } = string.Empty;
+ public bool CoverImageLocked { get; init; }
///
/// Number of Series in the Collection
///
- public int ItemCount { get; set; }
+ public int ItemCount { get; init; }
///
/// Owner of the Collection
///
- public string? Owner { get; set; }
+ public string? Owner { get; init; }
///
/// Last time Kavita Synced the Collection with an upstream source (for non Kavita sourced collections)
///
- public DateTime LastSyncUtc { get; set; }
+ public DateTime LastSyncUtc { get; init; }
///
/// Who created/manages the list. Non-Kavita lists are not editable by the user, except to promote
///
- public ScrobbleProvider Source { get; set; } = ScrobbleProvider.Kavita;
+ public ScrobbleProvider Source { get; init; } = ScrobbleProvider.Kavita;
///
/// For Non-Kavita sourced collections, the url to sync from
///
- public string? SourceUrl { get; set; }
+ public string? SourceUrl { get; init; }
///
/// Total number of items as of the last sync. Not applicable for Kavita managed collections.
///
- public int TotalSourceCount { get; set; }
+ public int TotalSourceCount { get; init; }
///
/// A
separated string of all missing series
///
- public string? MissingSeriesFromSource { get; set; }
+ public string? MissingSeriesFromSource { get; init; }
public void ResetColorScape()
{
diff --git a/API/DTOs/CollectionTags/CollectionTagBulkAddDto.cs b/API/DTOs/CollectionTags/CollectionTagBulkAddDto.cs
index 1d078959d..0a2270fbf 100644
--- a/API/DTOs/CollectionTags/CollectionTagBulkAddDto.cs
+++ b/API/DTOs/CollectionTags/CollectionTagBulkAddDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.CollectionTags;
-public class CollectionTagBulkAddDto
+public sealed record CollectionTagBulkAddDto
{
///
/// Collection Tag Id
diff --git a/API/DTOs/CollectionTags/CollectionTagDto.cs b/API/DTOs/CollectionTags/CollectionTagDto.cs
index ec9939ebd..911622051 100644
--- a/API/DTOs/CollectionTags/CollectionTagDto.cs
+++ b/API/DTOs/CollectionTags/CollectionTagDto.cs
@@ -3,15 +3,21 @@
namespace API.DTOs.CollectionTags;
[Obsolete("Use AppUserCollectionDto")]
-public class CollectionTagDto
+public sealed record CollectionTagDto
{
+ ///
public int Id { get; set; }
+ ///
public string Title { get; set; } = default!;
+ ///
public string Summary { get; set; } = default!;
+ ///
public bool Promoted { get; set; }
///
/// The cover image string. This is used on Frontend to show or hide the Cover Image
///
+ ///
public string CoverImage { get; set; } = default!;
+ ///
public bool CoverImageLocked { get; set; }
}
diff --git a/API/DTOs/CollectionTags/UpdateSeriesForTagDto.cs b/API/DTOs/CollectionTags/UpdateSeriesForTagDto.cs
index 19e9a11e2..139834a60 100644
--- a/API/DTOs/CollectionTags/UpdateSeriesForTagDto.cs
+++ b/API/DTOs/CollectionTags/UpdateSeriesForTagDto.cs
@@ -4,7 +4,7 @@ using API.DTOs.Collection;
namespace API.DTOs.CollectionTags;
-public class UpdateSeriesForTagDto
+public sealed record UpdateSeriesForTagDto
{
public AppUserCollectionDto Tag { get; init; } = default!;
public IEnumerable SeriesIdsToRemove { get; init; } = default!;
diff --git a/API/DTOs/ColorScape.cs b/API/DTOs/ColorScape.cs
index d95346af7..5351f2351 100644
--- a/API/DTOs/ColorScape.cs
+++ b/API/DTOs/ColorScape.cs
@@ -4,7 +4,7 @@
///
/// A primary and secondary color
///
-public class ColorScape
+public sealed record ColorScape
{
public required string? Primary { get; set; }
public required string? Secondary { get; set; }
diff --git a/API/DTOs/CopySettingsFromLibraryDto.cs b/API/DTOs/CopySettingsFromLibraryDto.cs
index ee75f7422..5ca5ead51 100644
--- a/API/DTOs/CopySettingsFromLibraryDto.cs
+++ b/API/DTOs/CopySettingsFromLibraryDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs;
-public class CopySettingsFromLibraryDto
+public sealed record CopySettingsFromLibraryDto
{
public int SourceLibraryId { get; set; }
public List TargetLibraryIds { get; set; }
diff --git a/API/DTOs/CoverDb/CoverDbAuthor.cs b/API/DTOs/CoverDb/CoverDbAuthor.cs
index 2f023398a..ca924801f 100644
--- a/API/DTOs/CoverDb/CoverDbAuthor.cs
+++ b/API/DTOs/CoverDb/CoverDbAuthor.cs
@@ -3,7 +3,7 @@ using YamlDotNet.Serialization;
namespace API.DTOs.CoverDb;
-public class CoverDbAuthor
+public sealed record CoverDbAuthor
{
[YamlMember(Alias = "name", ApplyNamingConventions = false)]
public string Name { get; set; }
diff --git a/API/DTOs/CoverDb/CoverDbPeople.cs b/API/DTOs/CoverDb/CoverDbPeople.cs
index c0f5e327e..2e825eac7 100644
--- a/API/DTOs/CoverDb/CoverDbPeople.cs
+++ b/API/DTOs/CoverDb/CoverDbPeople.cs
@@ -3,7 +3,7 @@ using YamlDotNet.Serialization;
namespace API.DTOs.CoverDb;
-public class CoverDbPeople
+public sealed record CoverDbPeople
{
[YamlMember(Alias = "people", ApplyNamingConventions = false)]
public List People { get; set; } = new List();
diff --git a/API/DTOs/CoverDb/CoverDbPersonIds.cs b/API/DTOs/CoverDb/CoverDbPersonIds.cs
index 9c59415e6..5816bb479 100644
--- a/API/DTOs/CoverDb/CoverDbPersonIds.cs
+++ b/API/DTOs/CoverDb/CoverDbPersonIds.cs
@@ -3,7 +3,7 @@
namespace API.DTOs.CoverDb;
#nullable enable
-public class CoverDbPersonIds
+public sealed record CoverDbPersonIds
{
[YamlMember(Alias = "hardcover_id", ApplyNamingConventions = false)]
public string? HardcoverId { get; set; } = null;
diff --git a/API/DTOs/Dashboard/DashboardStreamDto.cs b/API/DTOs/Dashboard/DashboardStreamDto.cs
index 59e5f4f7d..297a706b1 100644
--- a/API/DTOs/Dashboard/DashboardStreamDto.cs
+++ b/API/DTOs/Dashboard/DashboardStreamDto.cs
@@ -4,7 +4,7 @@ using API.Entities.Enums;
namespace API.DTOs.Dashboard;
-public class DashboardStreamDto
+public sealed record DashboardStreamDto
{
public int Id { get; set; }
public required string Name { get; set; }
diff --git a/API/DTOs/Dashboard/GroupedSeriesDto.cs b/API/DTOs/Dashboard/GroupedSeriesDto.cs
index 3b283de34..940e42c40 100644
--- a/API/DTOs/Dashboard/GroupedSeriesDto.cs
+++ b/API/DTOs/Dashboard/GroupedSeriesDto.cs
@@ -5,7 +5,7 @@ namespace API.DTOs.Dashboard;
///
/// This is a representation of a Series with some amount of underlying files within it. This is used for Recently Updated Series section
///
-public class GroupedSeriesDto
+public sealed record GroupedSeriesDto
{
public string SeriesName { get; set; } = default!;
public int SeriesId { get; set; }
diff --git a/API/DTOs/Dashboard/RecentlyAddedItemDto.cs b/API/DTOs/Dashboard/RecentlyAddedItemDto.cs
index 2e5658e2e..bb0360b30 100644
--- a/API/DTOs/Dashboard/RecentlyAddedItemDto.cs
+++ b/API/DTOs/Dashboard/RecentlyAddedItemDto.cs
@@ -6,7 +6,7 @@ namespace API.DTOs.Dashboard;
///
/// A mesh of data for Recently added volume/chapters
///
-public class RecentlyAddedItemDto
+public sealed record RecentlyAddedItemDto
{
public string SeriesName { get; set; } = default!;
public int SeriesId { get; set; }
diff --git a/API/DTOs/Dashboard/SmartFilterDto.cs b/API/DTOs/Dashboard/SmartFilterDto.cs
index b23a74c69..c1bc4d7e1 100644
--- a/API/DTOs/Dashboard/SmartFilterDto.cs
+++ b/API/DTOs/Dashboard/SmartFilterDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Dashboard;
-public class SmartFilterDto
+public sealed record SmartFilterDto
{
public int Id { get; set; }
public required string Name { get; set; }
diff --git a/API/DTOs/Dashboard/UpdateDashboardStreamPositionDto.cs b/API/DTOs/Dashboard/UpdateDashboardStreamPositionDto.cs
index c2320f1a9..476a0732e 100644
--- a/API/DTOs/Dashboard/UpdateDashboardStreamPositionDto.cs
+++ b/API/DTOs/Dashboard/UpdateDashboardStreamPositionDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Dashboard;
-public class UpdateDashboardStreamPositionDto
+public sealed record UpdateDashboardStreamPositionDto
{
public int FromPosition { get; set; }
public int ToPosition { get; set; }
diff --git a/API/DTOs/Dashboard/UpdateStreamPositionDto.cs b/API/DTOs/Dashboard/UpdateStreamPositionDto.cs
index f9005a585..8de0ffa6f 100644
--- a/API/DTOs/Dashboard/UpdateStreamPositionDto.cs
+++ b/API/DTOs/Dashboard/UpdateStreamPositionDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Dashboard;
-public class UpdateStreamPositionDto
+public sealed record UpdateStreamPositionDto
{
public int FromPosition { get; set; }
public int ToPosition { get; set; }
diff --git a/API/DTOs/DeleteChaptersDto.cs b/API/DTOs/DeleteChaptersDto.cs
index cbd21df36..9fad2f1fb 100644
--- a/API/DTOs/DeleteChaptersDto.cs
+++ b/API/DTOs/DeleteChaptersDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs;
-public class DeleteChaptersDto
+public sealed record DeleteChaptersDto
{
public IList ChapterIds { get; set; } = default!;
}
diff --git a/API/DTOs/DeleteSeriesDto.cs b/API/DTOs/DeleteSeriesDto.cs
index 12687fc25..ec9ba0c68 100644
--- a/API/DTOs/DeleteSeriesDto.cs
+++ b/API/DTOs/DeleteSeriesDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs;
-public class DeleteSeriesDto
+public sealed record DeleteSeriesDto
{
public IList SeriesIds { get; set; } = default!;
}
diff --git a/API/DTOs/Device/CreateDeviceDto.cs b/API/DTOs/Device/CreateDeviceDto.cs
index 7e59483fa..a8fdb6bc9 100644
--- a/API/DTOs/Device/CreateDeviceDto.cs
+++ b/API/DTOs/Device/CreateDeviceDto.cs
@@ -3,7 +3,7 @@ using API.Entities.Enums.Device;
namespace API.DTOs.Device;
-public class CreateDeviceDto
+public sealed record CreateDeviceDto
{
[Required]
public string Name { get; set; } = default!;
diff --git a/API/DTOs/Device/DeviceDto.cs b/API/DTOs/Device/DeviceDto.cs
index b2e83e6fc..42140dcc1 100644
--- a/API/DTOs/Device/DeviceDto.cs
+++ b/API/DTOs/Device/DeviceDto.cs
@@ -6,7 +6,7 @@ namespace API.DTOs.Device;
///
/// A Device is an entity that can receive data from Kavita (kindle)
///
-public class DeviceDto
+public sealed record DeviceDto
{
///
/// The device Id
diff --git a/API/DTOs/Device/SendSeriesToDeviceDto.cs b/API/DTOs/Device/SendSeriesToDeviceDto.cs
index a0a907464..58ce2293b 100644
--- a/API/DTOs/Device/SendSeriesToDeviceDto.cs
+++ b/API/DTOs/Device/SendSeriesToDeviceDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Device;
-public class SendSeriesToDeviceDto
+public sealed record SendSeriesToDeviceDto
{
public int DeviceId { get; set; }
public int SeriesId { get; set; }
diff --git a/API/DTOs/Device/SendToDeviceDto.cs b/API/DTOs/Device/SendToDeviceDto.cs
index fd88eaf59..a7a4dc0ff 100644
--- a/API/DTOs/Device/SendToDeviceDto.cs
+++ b/API/DTOs/Device/SendToDeviceDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Device;
-public class SendToDeviceDto
+public sealed record SendToDeviceDto
{
public int DeviceId { get; set; }
public IReadOnlyList ChapterIds { get; set; } = default!;
diff --git a/API/DTOs/Device/UpdateDeviceDto.cs b/API/DTOs/Device/UpdateDeviceDto.cs
index d28d372c3..2c3e72ea1 100644
--- a/API/DTOs/Device/UpdateDeviceDto.cs
+++ b/API/DTOs/Device/UpdateDeviceDto.cs
@@ -3,7 +3,7 @@ using API.Entities.Enums.Device;
namespace API.DTOs.Device;
-public class UpdateDeviceDto
+public sealed record UpdateDeviceDto
{
[Required]
public int Id { get; set; }
diff --git a/API/DTOs/Downloads/DownloadBookmarkDto.cs b/API/DTOs/Downloads/DownloadBookmarkDto.cs
index 5b7240b68..00f763dac 100644
--- a/API/DTOs/Downloads/DownloadBookmarkDto.cs
+++ b/API/DTOs/Downloads/DownloadBookmarkDto.cs
@@ -4,7 +4,7 @@ using API.DTOs.Reader;
namespace API.DTOs.Downloads;
-public class DownloadBookmarkDto
+public sealed record DownloadBookmarkDto
{
[Required]
public IEnumerable Bookmarks { get; set; } = default!;
diff --git a/API/DTOs/Email/ConfirmationEmailDto.cs b/API/DTOs/Email/ConfirmationEmailDto.cs
index 1a48c9974..197395794 100644
--- a/API/DTOs/Email/ConfirmationEmailDto.cs
+++ b/API/DTOs/Email/ConfirmationEmailDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Email;
-public class ConfirmationEmailDto
+public sealed record ConfirmationEmailDto
{
public string InvitingUser { get; init; } = default!;
public string EmailAddress { get; init; } = default!;
diff --git a/API/DTOs/Email/EmailHistoryDto.cs b/API/DTOs/Email/EmailHistoryDto.cs
index ca3549550..c2968d091 100644
--- a/API/DTOs/Email/EmailHistoryDto.cs
+++ b/API/DTOs/Email/EmailHistoryDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Email;
-public class EmailHistoryDto
+public sealed record EmailHistoryDto
{
public long Id { get; set; }
public bool Sent { get; set; }
diff --git a/API/DTOs/Email/EmailMigrationDto.cs b/API/DTOs/Email/EmailMigrationDto.cs
index f051e7337..5354afdaa 100644
--- a/API/DTOs/Email/EmailMigrationDto.cs
+++ b/API/DTOs/Email/EmailMigrationDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Email;
-public class EmailMigrationDto
+public sealed record EmailMigrationDto
{
public string EmailAddress { get; init; } = default!;
public string Username { get; init; } = default!;
diff --git a/API/DTOs/Email/EmailTestResultDto.cs b/API/DTOs/Email/EmailTestResultDto.cs
index 263e725c4..9be868eab 100644
--- a/API/DTOs/Email/EmailTestResultDto.cs
+++ b/API/DTOs/Email/EmailTestResultDto.cs
@@ -3,7 +3,7 @@
///
/// Represents if Test Email Service URL was successful or not and if any error occured
///
-public class EmailTestResultDto
+public sealed record EmailTestResultDto
{
public bool Successful { get; set; }
public string ErrorMessage { get; set; } = default!;
diff --git a/API/DTOs/Email/PasswordResetEmailDto.cs b/API/DTOs/Email/PasswordResetEmailDto.cs
index 06abba171..9fda066a9 100644
--- a/API/DTOs/Email/PasswordResetEmailDto.cs
+++ b/API/DTOs/Email/PasswordResetEmailDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Email;
-public class PasswordResetEmailDto
+public sealed record PasswordResetEmailDto
{
public string EmailAddress { get; init; } = default!;
public string ServerConfirmationLink { get; init; } = default!;
diff --git a/API/DTOs/Email/SendToDto.cs b/API/DTOs/Email/SendToDto.cs
index 1261d110c..eacd29449 100644
--- a/API/DTOs/Email/SendToDto.cs
+++ b/API/DTOs/Email/SendToDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Email;
-public class SendToDto
+public sealed record SendToDto
{
public string DestinationEmail { get; set; } = default!;
public IEnumerable FilePaths { get; set; } = default!;
diff --git a/API/DTOs/Email/TestEmailDto.cs b/API/DTOs/Email/TestEmailDto.cs
index 37c12ed30..44c11bd6c 100644
--- a/API/DTOs/Email/TestEmailDto.cs
+++ b/API/DTOs/Email/TestEmailDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Email;
-public class TestEmailDto
+public sealed record TestEmailDto
{
public string Url { get; set; } = default!;
}
diff --git a/API/DTOs/Filtering/FilterDto.cs b/API/DTOs/Filtering/FilterDto.cs
index 9205a7bba..cb3374838 100644
--- a/API/DTOs/Filtering/FilterDto.cs
+++ b/API/DTOs/Filtering/FilterDto.cs
@@ -5,7 +5,7 @@ using API.Entities.Enums;
namespace API.DTOs.Filtering;
#nullable enable
-public class FilterDto
+public sealed record FilterDto
{
///
/// The type of Formats you want to be returned. An empty list will return all formats back
diff --git a/API/DTOs/Filtering/LanguageDto.cs b/API/DTOs/Filtering/LanguageDto.cs
index bc7ebb5cc..dde85f07e 100644
--- a/API/DTOs/Filtering/LanguageDto.cs
+++ b/API/DTOs/Filtering/LanguageDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Filtering;
-public class LanguageDto
+public sealed record LanguageDto
{
public required string IsoCode { get; set; }
public required string Title { get; set; }
diff --git a/API/DTOs/Filtering/PersonSortField.cs b/API/DTOs/Filtering/PersonSortField.cs
new file mode 100644
index 000000000..5268a1bf9
--- /dev/null
+++ b/API/DTOs/Filtering/PersonSortField.cs
@@ -0,0 +1,8 @@
+namespace API.DTOs.Filtering;
+
+public enum PersonSortField
+{
+ Name = 1,
+ SeriesCount = 2,
+ ChapterCount = 3
+}
diff --git a/API/DTOs/Filtering/Range.cs b/API/DTOs/Filtering/Range.cs
index a75164fa3..e697f26e1 100644
--- a/API/DTOs/Filtering/Range.cs
+++ b/API/DTOs/Filtering/Range.cs
@@ -4,7 +4,7 @@
///
/// Represents a range between two int/float/double
///
-public class Range
+public sealed record Range
{
public T? Min { get; init; }
public T? Max { get; init; }
diff --git a/API/DTOs/Filtering/ReadStatus.cs b/API/DTOs/Filtering/ReadStatus.cs
index eeb786714..81498ecb5 100644
--- a/API/DTOs/Filtering/ReadStatus.cs
+++ b/API/DTOs/Filtering/ReadStatus.cs
@@ -3,7 +3,7 @@
///
/// Represents the Reading Status. This is a flag and allows multiple statues
///
-public class ReadStatus
+public sealed record ReadStatus
{
public bool NotRead { get; set; } = true;
public bool InProgress { get; set; } = true;
diff --git a/API/DTOs/Filtering/SortOptions.cs b/API/DTOs/Filtering/SortOptions.cs
index 00bf91675..18f2b17ea 100644
--- a/API/DTOs/Filtering/SortOptions.cs
+++ b/API/DTOs/Filtering/SortOptions.cs
@@ -3,8 +3,17 @@
///
/// Sorting Options for a query
///
-public class SortOptions
+public sealed record SortOptions
{
public SortField SortField { get; set; }
public bool IsAscending { get; set; } = true;
}
+
+///
+/// All Sorting Options for a query related to Person Entity
+///
+public sealed record PersonSortOptions
+{
+ public PersonSortField SortField { get; set; }
+ public bool IsAscending { get; set; } = true;
+}
diff --git a/API/DTOs/Filtering/v2/DecodeFilterDto.cs b/API/DTOs/Filtering/v2/DecodeFilterDto.cs
index 18dc166e7..db4c7ecce 100644
--- a/API/DTOs/Filtering/v2/DecodeFilterDto.cs
+++ b/API/DTOs/Filtering/v2/DecodeFilterDto.cs
@@ -3,7 +3,7 @@
///
/// For requesting an encoded filter to be decoded
///
-public class DecodeFilterDto
+public sealed record DecodeFilterDto
{
public string EncodedFilter { get; set; }
}
diff --git a/API/DTOs/Filtering/v2/FilterField.cs b/API/DTOs/Filtering/v2/FilterField.cs
index 5323f2b48..246a92a90 100644
--- a/API/DTOs/Filtering/v2/FilterField.cs
+++ b/API/DTOs/Filtering/v2/FilterField.cs
@@ -56,5 +56,12 @@ public enum FilterField
/// Last time User Read
///
ReadLast = 32,
-
+}
+
+public enum PersonFilterField
+{
+ Role = 1,
+ Name = 2,
+ SeriesCount = 3,
+ ChapterCount = 4,
}
diff --git a/API/DTOs/Filtering/v2/FilterStatementDto.cs b/API/DTOs/Filtering/v2/FilterStatementDto.cs
index a6192093e..8c99bd24c 100644
--- a/API/DTOs/Filtering/v2/FilterStatementDto.cs
+++ b/API/DTOs/Filtering/v2/FilterStatementDto.cs
@@ -1,8 +1,17 @@
-namespace API.DTOs.Filtering.v2;
+using API.DTOs.Metadata.Browse.Requests;
-public class FilterStatementDto
+namespace API.DTOs.Filtering.v2;
+
+public sealed record FilterStatementDto
{
public FilterComparison Comparison { get; set; }
public FilterField Field { get; set; }
public string Value { get; set; }
}
+
+public sealed record PersonFilterStatementDto
+{
+ public FilterComparison Comparison { get; set; }
+ public PersonFilterField Field { get; set; }
+ public string Value { get; set; }
+}
diff --git a/API/DTOs/Filtering/v2/FilterV2Dto.cs b/API/DTOs/Filtering/v2/FilterV2Dto.cs
index 5bc50ff2f..a247a17a6 100644
--- a/API/DTOs/Filtering/v2/FilterV2Dto.cs
+++ b/API/DTOs/Filtering/v2/FilterV2Dto.cs
@@ -6,7 +6,7 @@ namespace API.DTOs.Filtering.v2;
///
/// Metadata filtering for v2 API only
///
-public class FilterV2Dto
+public sealed record FilterV2Dto
{
///
/// Not used in the UI.
@@ -16,7 +16,7 @@ public class FilterV2Dto
/// The name of the filter
///
public string? Name { get; set; }
- public ICollection Statements { get; set; } = new List();
+ public ICollection Statements { get; set; } = [];
public FilterCombination Combination { get; set; } = FilterCombination.And;
public SortOptions? SortOptions { get; set; }
diff --git a/API/DTOs/Jobs/JobDto.cs b/API/DTOs/Jobs/JobDto.cs
index 648765a34..55419811f 100644
--- a/API/DTOs/Jobs/JobDto.cs
+++ b/API/DTOs/Jobs/JobDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Jobs;
-public class JobDto
+public sealed record JobDto
{
///
/// Job Id
diff --git a/API/DTOs/JumpBar/JumpKeyDto.cs b/API/DTOs/JumpBar/JumpKeyDto.cs
index 5a98a85ca..8dc5b4a8e 100644
--- a/API/DTOs/JumpBar/JumpKeyDto.cs
+++ b/API/DTOs/JumpBar/JumpKeyDto.cs
@@ -3,7 +3,7 @@
///
/// Represents an individual button in a Jump Bar
///
-public class JumpKeyDto
+public sealed record JumpKeyDto
{
///
/// Number of items in this Key
diff --git a/API/DTOs/KavitaLocale.cs b/API/DTOs/KavitaLocale.cs
index decfb7395..51868605f 100644
--- a/API/DTOs/KavitaLocale.cs
+++ b/API/DTOs/KavitaLocale.cs
@@ -1,6 +1,6 @@
namespace API.DTOs;
-public class KavitaLocale
+public sealed record KavitaLocale
{
public string FileName { get; set; } // Key
public string RenderName { get; set; }
diff --git a/API/DTOs/KavitaPlus/Account/AniListUpdateDto.cs b/API/DTOs/KavitaPlus/Account/AniListUpdateDto.cs
index c6d2e07cc..c053bd34e 100644
--- a/API/DTOs/KavitaPlus/Account/AniListUpdateDto.cs
+++ b/API/DTOs/KavitaPlus/Account/AniListUpdateDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.KavitaPlus.Account;
-public class AniListUpdateDto
+public sealed record AniListUpdateDto
{
public string Token { get; set; }
}
diff --git a/API/DTOs/KavitaPlus/Account/UserTokenInfo.cs b/API/DTOs/KavitaPlus/Account/UserTokenInfo.cs
index 220bd9e7e..340ad0f4c 100644
--- a/API/DTOs/KavitaPlus/Account/UserTokenInfo.cs
+++ b/API/DTOs/KavitaPlus/Account/UserTokenInfo.cs
@@ -5,7 +5,7 @@ namespace API.DTOs.KavitaPlus.Account;
///
/// Represents information around a user's tokens and their status
///
-public class UserTokenInfo
+public sealed record UserTokenInfo
{
public int UserId { get; set; }
public string Username { get; set; }
diff --git a/API/DTOs/KavitaPlus/ExternalMetadata/ExternalMetadataIdsDto.cs b/API/DTOs/KavitaPlus/ExternalMetadata/ExternalMetadataIdsDto.cs
index 547bb63a8..c05ff0567 100644
--- a/API/DTOs/KavitaPlus/ExternalMetadata/ExternalMetadataIdsDto.cs
+++ b/API/DTOs/KavitaPlus/ExternalMetadata/ExternalMetadataIdsDto.cs
@@ -6,7 +6,7 @@ namespace API.DTOs.KavitaPlus.ExternalMetadata;
///
/// Used for matching and fetching metadata on a series
///
-internal class ExternalMetadataIdsDto
+public sealed record ExternalMetadataIdsDto
{
public long? MalId { get; set; }
public int? AniListId { get; set; }
diff --git a/API/DTOs/KavitaPlus/ExternalMetadata/MatchSeriesRequestDto.cs b/API/DTOs/KavitaPlus/ExternalMetadata/MatchSeriesRequestDto.cs
index f63fe5a9e..a7359d69b 100644
--- a/API/DTOs/KavitaPlus/ExternalMetadata/MatchSeriesRequestDto.cs
+++ b/API/DTOs/KavitaPlus/ExternalMetadata/MatchSeriesRequestDto.cs
@@ -4,14 +4,18 @@ using API.DTOs.Scrobbling;
namespace API.DTOs.KavitaPlus.ExternalMetadata;
#nullable enable
-internal class MatchSeriesRequestDto
+///
+/// Represents a request to match some series from Kavita to an external id which K+ uses.
+///
+public sealed record MatchSeriesRequestDto
{
- public string SeriesName { get; set; }
- public ICollection AlternativeNames { get; set; }
+ public required string SeriesName { get; set; }
+ public ICollection AlternativeNames { get; set; } = [];
public int Year { get; set; } = 0;
- public string Query { get; set; }
+ public string? Query { get; set; }
public int? AniListId { get; set; }
public long? MalId { get; set; }
public string? HardcoverId { get; set; }
+ public int? CbrId { get; set; }
public PlusMediaFormat Format { get; set; }
}
diff --git a/API/DTOs/KavitaPlus/ExternalMetadata/SeriesDetailPlusApiDto.cs b/API/DTOs/KavitaPlus/ExternalMetadata/SeriesDetailPlusApiDto.cs
index 26411bce7..84e9bbf3e 100644
--- a/API/DTOs/KavitaPlus/ExternalMetadata/SeriesDetailPlusApiDto.cs
+++ b/API/DTOs/KavitaPlus/ExternalMetadata/SeriesDetailPlusApiDto.cs
@@ -1,11 +1,12 @@
using System.Collections.Generic;
+using API.DTOs.KavitaPlus.Metadata;
using API.DTOs.Recommendation;
using API.DTOs.Scrobbling;
using API.DTOs.SeriesDetail;
namespace API.DTOs.KavitaPlus.ExternalMetadata;
-internal class SeriesDetailPlusApiDto
+public sealed record SeriesDetailPlusApiDto
{
public IEnumerable Recommendations { get; set; }
public IEnumerable Reviews { get; set; }
diff --git a/API/DTOs/KavitaPlus/License/EncryptLicenseDto.cs b/API/DTOs/KavitaPlus/License/EncryptLicenseDto.cs
index eedbed2ef..dd85dd063 100644
--- a/API/DTOs/KavitaPlus/License/EncryptLicenseDto.cs
+++ b/API/DTOs/KavitaPlus/License/EncryptLicenseDto.cs
@@ -1,7 +1,7 @@
namespace API.DTOs.KavitaPlus.License;
#nullable enable
-public class EncryptLicenseDto
+public sealed record EncryptLicenseDto
{
public required string License { get; set; }
public required string InstallId { get; set; }
diff --git a/API/DTOs/KavitaPlus/License/LicenseInfoDto.cs b/API/DTOs/KavitaPlus/License/LicenseInfoDto.cs
index 398556aac..2cd9b5896 100644
--- a/API/DTOs/KavitaPlus/License/LicenseInfoDto.cs
+++ b/API/DTOs/KavitaPlus/License/LicenseInfoDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.KavitaPlus.License;
-public class LicenseInfoDto
+public sealed record LicenseInfoDto
{
///
/// If cancelled, will represent cancellation date. If not, will represent repayment date
diff --git a/API/DTOs/KavitaPlus/License/LicenseValidDto.cs b/API/DTOs/KavitaPlus/License/LicenseValidDto.cs
index 56ee6cf73..a7bd476ce 100644
--- a/API/DTOs/KavitaPlus/License/LicenseValidDto.cs
+++ b/API/DTOs/KavitaPlus/License/LicenseValidDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.KavitaPlus.License;
-public class LicenseValidDto
+public sealed record LicenseValidDto
{
public required string License { get; set; }
public required string InstallId { get; set; }
diff --git a/API/DTOs/KavitaPlus/License/ResetLicenseDto.cs b/API/DTOs/KavitaPlus/License/ResetLicenseDto.cs
index 60496ee0e..d0fd9b666 100644
--- a/API/DTOs/KavitaPlus/License/ResetLicenseDto.cs
+++ b/API/DTOs/KavitaPlus/License/ResetLicenseDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.KavitaPlus.License;
-public class ResetLicenseDto
+public sealed record ResetLicenseDto
{
public required string License { get; set; }
public required string InstallId { get; set; }
diff --git a/API/DTOs/KavitaPlus/License/UpdateLicenseDto.cs b/API/DTOs/KavitaPlus/License/UpdateLicenseDto.cs
index 4621810f0..28b47efbe 100644
--- a/API/DTOs/KavitaPlus/License/UpdateLicenseDto.cs
+++ b/API/DTOs/KavitaPlus/License/UpdateLicenseDto.cs
@@ -1,7 +1,7 @@
namespace API.DTOs.KavitaPlus.License;
#nullable enable
-public class UpdateLicenseDto
+public sealed record UpdateLicenseDto
{
///
/// License Key received from Kavita+
diff --git a/API/DTOs/KavitaPlus/Manage/ManageMatchFilterDto.cs b/API/DTOs/KavitaPlus/Manage/ManageMatchFilterDto.cs
index 60bed32b0..c394cf8d4 100644
--- a/API/DTOs/KavitaPlus/Manage/ManageMatchFilterDto.cs
+++ b/API/DTOs/KavitaPlus/Manage/ManageMatchFilterDto.cs
@@ -12,8 +12,12 @@ public enum MatchStateOption
DontMatch = 4
}
-public class ManageMatchFilterDto
+public sealed record ManageMatchFilterDto
{
public MatchStateOption MatchStateOption { get; set; } = MatchStateOption.All;
+ ///
+ /// Library Type in int form. -1 indicates to ignore the field.
+ ///
+ public int LibraryType { get; set; } = -1;
public string SearchTerm { get; set; } = string.Empty;
}
diff --git a/API/DTOs/KavitaPlus/Manage/ManageMatchSeriesDto.cs b/API/DTOs/KavitaPlus/Manage/ManageMatchSeriesDto.cs
index 14617e7f0..a51e63ee9 100644
--- a/API/DTOs/KavitaPlus/Manage/ManageMatchSeriesDto.cs
+++ b/API/DTOs/KavitaPlus/Manage/ManageMatchSeriesDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.KavitaPlus.Manage;
-public class ManageMatchSeriesDto
+public sealed record ManageMatchSeriesDto
{
public SeriesDto Series { get; set; }
public bool IsMatched { get; set; }
diff --git a/API/DTOs/KavitaPlus/Metadata/ExternalChapterDto.cs b/API/DTOs/KavitaPlus/Metadata/ExternalChapterDto.cs
index 6b711513c..add9ca723 100644
--- a/API/DTOs/KavitaPlus/Metadata/ExternalChapterDto.cs
+++ b/API/DTOs/KavitaPlus/Metadata/ExternalChapterDto.cs
@@ -3,11 +3,12 @@ using System.Collections.Generic;
using API.DTOs.SeriesDetail;
namespace API.DTOs.KavitaPlus.Metadata;
+#nullable enable
///
/// Information about an individual issue/chapter/book from Kavita+
///
-public class ExternalChapterDto
+public sealed record ExternalChapterDto
{
public string Title { get; set; }
diff --git a/API/DTOs/KavitaPlus/Metadata/ExternalSeriesDetailDto.cs b/API/DTOs/KavitaPlus/Metadata/ExternalSeriesDetailDto.cs
index 2ea746214..6704bf697 100644
--- a/API/DTOs/KavitaPlus/Metadata/ExternalSeriesDetailDto.cs
+++ b/API/DTOs/KavitaPlus/Metadata/ExternalSeriesDetailDto.cs
@@ -1,16 +1,16 @@
using System;
using System.Collections.Generic;
-using API.DTOs.KavitaPlus.Metadata;
+using API.DTOs.Recommendation;
using API.DTOs.Scrobbling;
using API.Services.Plus;
-namespace API.DTOs.Recommendation;
+namespace API.DTOs.KavitaPlus.Metadata;
#nullable enable
///
/// This is AniListSeries
///
-public class ExternalSeriesDetailDto
+public sealed record ExternalSeriesDetailDto
{
public string Name { get; set; }
public int? AniListId { get; set; }
@@ -29,7 +29,9 @@ public class ExternalSeriesDetailDto
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }
public int AverageScore { get; set; }
+ /// AniList returns the total count of unique chapters, includes 1.1 for example
public int Chapters { get; set; }
+ /// AniList returns the total count of unique volumes, includes 1.1 for example
public int Volumes { get; set; }
public IList? Relations { get; set; } = [];
public IList? Characters { get; set; } = [];
diff --git a/API/DTOs/KavitaPlus/Metadata/MetadataFieldMappingDto.cs b/API/DTOs/KavitaPlus/Metadata/MetadataFieldMappingDto.cs
index 796cfeb1a..a9debabd1 100644
--- a/API/DTOs/KavitaPlus/Metadata/MetadataFieldMappingDto.cs
+++ b/API/DTOs/KavitaPlus/Metadata/MetadataFieldMappingDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.KavitaPlus.Metadata;
-public class MetadataFieldMappingDto
+public sealed record MetadataFieldMappingDto
{
public int Id { get; set; }
public MetadataFieldType SourceType { get; set; }
diff --git a/API/DTOs/KavitaPlus/Metadata/MetadataSettingsDto.cs b/API/DTOs/KavitaPlus/Metadata/MetadataSettingsDto.cs
index 1dd26a7bc..e9f6614bc 100644
--- a/API/DTOs/KavitaPlus/Metadata/MetadataSettingsDto.cs
+++ b/API/DTOs/KavitaPlus/Metadata/MetadataSettingsDto.cs
@@ -7,7 +7,7 @@ using NotImplementedException = System.NotImplementedException;
namespace API.DTOs.KavitaPlus.Metadata;
-public class MetadataSettingsDto
+public sealed record MetadataSettingsDto
{
///
/// If writing any sort of metadata from upstream (AniList, Hardcover) source is allowed
diff --git a/API/DTOs/KavitaPlus/Metadata/SeriesCharacter.cs b/API/DTOs/KavitaPlus/Metadata/SeriesCharacter.cs
index bb5a3f20a..2b57548cd 100644
--- a/API/DTOs/KavitaPlus/Metadata/SeriesCharacter.cs
+++ b/API/DTOs/KavitaPlus/Metadata/SeriesCharacter.cs
@@ -9,7 +9,7 @@ public enum CharacterRole
}
-public class SeriesCharacter
+public sealed record SeriesCharacter
{
public string Name { get; set; }
public required string Description { get; set; }
diff --git a/API/DTOs/KavitaPlus/Metadata/SeriesRelationship.cs b/API/DTOs/KavitaPlus/Metadata/SeriesRelationship.cs
index bd42e73a1..0b1f619a2 100644
--- a/API/DTOs/KavitaPlus/Metadata/SeriesRelationship.cs
+++ b/API/DTOs/KavitaPlus/Metadata/SeriesRelationship.cs
@@ -5,7 +5,7 @@ using API.Services.Plus;
namespace API.DTOs.KavitaPlus.Metadata;
-public class ALMediaTitle
+public sealed record ALMediaTitle
{
public string? EnglishTitle { get; set; }
public string RomajiTitle { get; set; }
@@ -13,7 +13,7 @@ public class ALMediaTitle
public string PreferredTitle { get; set; }
}
-public class SeriesRelationship
+public sealed record SeriesRelationship
{
public int AniListId { get; set; }
public int? MalId { get; set; }
diff --git a/API/DTOs/Koreader/KoreaderBookDto.cs b/API/DTOs/Koreader/KoreaderBookDto.cs
new file mode 100644
index 000000000..b66b7da3a
--- /dev/null
+++ b/API/DTOs/Koreader/KoreaderBookDto.cs
@@ -0,0 +1,33 @@
+using API.DTOs.Progress;
+
+namespace API.DTOs.Koreader;
+
+///
+/// This is the interface for receiving and sending updates to Koreader. The only fields
+/// that are actually used are the Document and Progress fields.
+///
+public class KoreaderBookDto
+{
+ ///
+ /// This is the Koreader hash of the book. It is used to identify the book.
+ ///
+ public string Document { get; set; }
+ ///
+ /// A randomly generated id from the koreader device. Only used to maintain the Koreader interface.
+ ///
+ public string Device_id { get; set; }
+ ///
+ /// The Koreader device name. Only used to maintain the Koreader interface.
+ ///
+ public string Device { get; set; }
+ ///
+ /// Percent progress of the book. Only used to maintain the Koreader interface.
+ ///
+ public float Percentage { get; set; }
+ ///
+ /// An XPath string read by Koreader to determine the location within the epub.
+ /// Essentially, it is Koreader's equivalent to ProgressDto.BookScrollId.
+ ///
+ ///
+ public string Progress { get; set; }
+}
diff --git a/API/DTOs/Koreader/KoreaderProgressUpdateDto.cs b/API/DTOs/Koreader/KoreaderProgressUpdateDto.cs
new file mode 100644
index 000000000..52a1d6cbd
--- /dev/null
+++ b/API/DTOs/Koreader/KoreaderProgressUpdateDto.cs
@@ -0,0 +1,15 @@
+using System;
+
+namespace API.DTOs.Koreader;
+
+public class KoreaderProgressUpdateDto
+{
+ ///
+ /// This is the Koreader hash of the book. It is used to identify the book.
+ ///
+ public string Document { get; set; }
+ ///
+ /// UTC Timestamp to return to KOReader
+ ///
+ public DateTime Timestamp { get; set; }
+}
diff --git a/API/DTOs/LibraryDto.cs b/API/DTOs/LibraryDto.cs
index 18dea9434..bd72ad2f0 100644
--- a/API/DTOs/LibraryDto.cs
+++ b/API/DTOs/LibraryDto.cs
@@ -1,12 +1,11 @@
using System;
-using System.Collections;
using System.Collections.Generic;
using API.Entities.Enums;
namespace API.DTOs;
#nullable enable
-public class LibraryDto
+public sealed record LibraryDto
{
public int Id { get; init; }
public string? Name { get; init; }
@@ -67,4 +66,12 @@ public class LibraryDto
/// This does not exclude the library from being linked to wrt Series Relationships
/// Requires a valid LicenseKey
public bool AllowMetadataMatching { get; set; } = true;
+ ///
+ /// Allow Kavita to read metadata (ComicInfo.xml, Epub, PDF)
+ ///
+ public bool EnableMetadata { get; set; } = true;
+ ///
+ /// Should Kavita remove sort articles "The" for the sort name
+ ///
+ public bool RemovePrefixForSortName { get; set; } = false;
}
diff --git a/API/DTOs/MangaFileDto.cs b/API/DTOs/MangaFileDto.cs
index 9f2f19a42..23bb37467 100644
--- a/API/DTOs/MangaFileDto.cs
+++ b/API/DTOs/MangaFileDto.cs
@@ -4,7 +4,7 @@ using API.Entities.Enums;
namespace API.DTOs;
#nullable enable
-public class MangaFileDto
+public sealed record MangaFileDto
{
public int Id { get; init; }
///
diff --git a/API/DTOs/MediaErrors/MediaErrorDto.cs b/API/DTOs/MediaErrors/MediaErrorDto.cs
index bfaf57124..b77ee88be 100644
--- a/API/DTOs/MediaErrors/MediaErrorDto.cs
+++ b/API/DTOs/MediaErrors/MediaErrorDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.MediaErrors;
-public class MediaErrorDto
+public sealed record MediaErrorDto
{
///
/// Format Type (RAR, ZIP, 7Zip, Epub, PDF)
diff --git a/API/DTOs/MemberDto.cs b/API/DTOs/MemberDto.cs
index 7b750b32f..f5f24b284 100644
--- a/API/DTOs/MemberDto.cs
+++ b/API/DTOs/MemberDto.cs
@@ -8,7 +8,7 @@ namespace API.DTOs;
///
/// Represents a member of a Kavita server.
///
-public class MemberDto
+public sealed record MemberDto
{
public int Id { get; init; }
public string? Username { get; init; }
diff --git a/API/DTOs/Metadata/AgeRatingDto.cs b/API/DTOs/Metadata/AgeRatingDto.cs
index 07523c3fe..bfa835ef5 100644
--- a/API/DTOs/Metadata/AgeRatingDto.cs
+++ b/API/DTOs/Metadata/AgeRatingDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Metadata;
-public class AgeRatingDto
+public sealed record AgeRatingDto
{
public AgeRating Value { get; set; }
public required string Title { get; set; }
diff --git a/API/DTOs/Metadata/Browse/BrowseGenreDto.cs b/API/DTOs/Metadata/Browse/BrowseGenreDto.cs
new file mode 100644
index 000000000..8044c7914
--- /dev/null
+++ b/API/DTOs/Metadata/Browse/BrowseGenreDto.cs
@@ -0,0 +1,13 @@
+namespace API.DTOs.Metadata.Browse;
+
+public sealed record BrowseGenreDto : GenreTagDto
+{
+ ///
+ /// Number of Series this Entity is on
+ ///
+ public int SeriesCount { get; set; }
+ ///
+ /// Number of Chapters this Entity is on
+ ///
+ public int ChapterCount { get; set; }
+}
diff --git a/API/DTOs/Person/BrowsePersonDto.cs b/API/DTOs/Metadata/Browse/BrowsePersonDto.cs
similarity index 65%
rename from API/DTOs/Person/BrowsePersonDto.cs
rename to API/DTOs/Metadata/Browse/BrowsePersonDto.cs
index 8d6999973..20f84b783 100644
--- a/API/DTOs/Person/BrowsePersonDto.cs
+++ b/API/DTOs/Metadata/Browse/BrowsePersonDto.cs
@@ -1,4 +1,6 @@
-namespace API.DTOs;
+using API.DTOs.Person;
+
+namespace API.DTOs.Metadata.Browse;
///
/// Used to browse writers and click in to see their series
@@ -10,7 +12,7 @@ public class BrowsePersonDto : PersonDto
///
public int SeriesCount { get; set; }
///
- /// Number or Issues this Person is the Writer for
+ /// Number of Issues this Person is the Writer for
///
- public int IssueCount { get; set; }
+ public int ChapterCount { get; set; }
}
diff --git a/API/DTOs/Metadata/Browse/BrowseTagDto.cs b/API/DTOs/Metadata/Browse/BrowseTagDto.cs
new file mode 100644
index 000000000..9a71876e3
--- /dev/null
+++ b/API/DTOs/Metadata/Browse/BrowseTagDto.cs
@@ -0,0 +1,13 @@
+namespace API.DTOs.Metadata.Browse;
+
+public sealed record BrowseTagDto : TagDto
+{
+ ///
+ /// Number of Series this Entity is on
+ ///
+ public int SeriesCount { get; set; }
+ ///
+ /// Number of Chapters this Entity is on
+ ///
+ public int ChapterCount { get; set; }
+}
diff --git a/API/DTOs/Metadata/Browse/Requests/BrowsePersonFilterDto.cs b/API/DTOs/Metadata/Browse/Requests/BrowsePersonFilterDto.cs
new file mode 100644
index 000000000..d41cf37f3
--- /dev/null
+++ b/API/DTOs/Metadata/Browse/Requests/BrowsePersonFilterDto.cs
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using API.DTOs.Filtering;
+using API.DTOs.Filtering.v2;
+using API.Entities.Enums;
+
+namespace API.DTOs.Metadata.Browse.Requests;
+#nullable enable
+
+public sealed record BrowsePersonFilterDto
+{
+ ///
+ /// Not used - For parity with Series Filter
+ ///
+ public int Id { get; set; }
+ ///
+ /// Not used - For parity with Series Filter
+ ///
+ public string? Name { get; set; }
+ public ICollection Statements { get; set; } = [];
+ public FilterCombination Combination { get; set; } = FilterCombination.And;
+ public PersonSortOptions? SortOptions { get; set; }
+
+ ///
+ /// Limit the number of rows returned. Defaults to not applying a limit (aka 0)
+ ///
+ public int LimitTo { get; set; } = 0;
+}
diff --git a/API/DTOs/Metadata/ChapterMetadataDto.cs b/API/DTOs/Metadata/ChapterMetadataDto.cs
index bbd93d618..c79436e24 100644
--- a/API/DTOs/Metadata/ChapterMetadataDto.cs
+++ b/API/DTOs/Metadata/ChapterMetadataDto.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using API.DTOs.Person;
using API.Entities.Enums;
namespace API.DTOs.Metadata;
@@ -9,7 +10,7 @@ namespace API.DTOs.Metadata;
/// Exclusively metadata about a given chapter
///
[Obsolete("Will not be maintained as of v0.8.1")]
-public class ChapterMetadataDto
+public sealed record ChapterMetadataDto
{
public int Id { get; set; }
public int ChapterId { get; set; }
diff --git a/API/DTOs/Metadata/GenreTagDto.cs b/API/DTOs/Metadata/GenreTagDto.cs
index cf05ebbff..13a339d38 100644
--- a/API/DTOs/Metadata/GenreTagDto.cs
+++ b/API/DTOs/Metadata/GenreTagDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Metadata;
-public class GenreTagDto
+public record GenreTagDto
{
public int Id { get; set; }
public required string Title { get; set; }
diff --git a/API/DTOs/Metadata/Matching/ExternalSeriesMatchDto.cs b/API/DTOs/Metadata/Matching/ExternalSeriesMatchDto.cs
index aefd697ba..774581b37 100644
--- a/API/DTOs/Metadata/Matching/ExternalSeriesMatchDto.cs
+++ b/API/DTOs/Metadata/Matching/ExternalSeriesMatchDto.cs
@@ -1,8 +1,9 @@
+using API.DTOs.KavitaPlus.Metadata;
using API.DTOs.Recommendation;
namespace API.DTOs.Metadata.Matching;
-public class ExternalSeriesMatchDto
+public sealed record ExternalSeriesMatchDto
{
public ExternalSeriesDetailDto Series { get; set; }
public float MatchRating { get; set; }
diff --git a/API/DTOs/Metadata/Matching/MatchSeriesDto.cs b/API/DTOs/Metadata/Matching/MatchSeriesDto.cs
index 1f401e787..bb497b9ab 100644
--- a/API/DTOs/Metadata/Matching/MatchSeriesDto.cs
+++ b/API/DTOs/Metadata/Matching/MatchSeriesDto.cs
@@ -3,7 +3,7 @@ namespace API.DTOs.Metadata.Matching;
///
/// Used for matching a series with Kavita+ for metadata and scrobbling
///
-public class MatchSeriesDto
+public sealed record MatchSeriesDto
{
///
/// When set, Kavita will stop attempting to match this series and will not perform any scrobbling
diff --git a/API/DTOs/Metadata/PublicationStatusDto.cs b/API/DTOs/Metadata/PublicationStatusDto.cs
index b8166a6e5..b4f12500a 100644
--- a/API/DTOs/Metadata/PublicationStatusDto.cs
+++ b/API/DTOs/Metadata/PublicationStatusDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Metadata;
-public class PublicationStatusDto
+public sealed record PublicationStatusDto
{
public PublicationStatus Value { get; set; }
public required string Title { get; set; }
diff --git a/API/DTOs/Metadata/TagDto.cs b/API/DTOs/Metadata/TagDto.cs
index 59e03a279..f5c925e1f 100644
--- a/API/DTOs/Metadata/TagDto.cs
+++ b/API/DTOs/Metadata/TagDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Metadata;
-public class TagDto
+public record TagDto
{
public int Id { get; set; }
public required string Title { get; set; }
diff --git a/API/DTOs/OPDS/Feed.cs b/API/DTOs/OPDS/Feed.cs
index 76a740b89..5f4c4b115 100644
--- a/API/DTOs/OPDS/Feed.cs
+++ b/API/DTOs/OPDS/Feed.cs
@@ -4,11 +4,13 @@ using System.Xml.Serialization;
namespace API.DTOs.OPDS;
+// TODO: OPDS Dtos are internal state, shouldn't be in DTO directory
+
///
///
///
[XmlRoot("feed", Namespace = "http://www.w3.org/2005/Atom")]
-public class Feed
+public sealed record Feed
{
[XmlElement("updated")]
public string Updated { get; init; } = DateTime.UtcNow.ToString("s");
diff --git a/API/DTOs/OPDS/FeedAuthor.cs b/API/DTOs/OPDS/FeedAuthor.cs
index 1fd3e6cd2..4196997dd 100644
--- a/API/DTOs/OPDS/FeedAuthor.cs
+++ b/API/DTOs/OPDS/FeedAuthor.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.OPDS;
-public class FeedAuthor
+public sealed record FeedAuthor
{
[XmlElement("name")]
public string Name { get; set; }
diff --git a/API/DTOs/OPDS/FeedCategory.cs b/API/DTOs/OPDS/FeedCategory.cs
index 3129fab60..2352b4af2 100644
--- a/API/DTOs/OPDS/FeedCategory.cs
+++ b/API/DTOs/OPDS/FeedCategory.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.OPDS;
-public class FeedCategory
+public sealed record FeedCategory
{
[XmlAttribute("scheme")]
public string Scheme { get; } = "http://www.bisg.org/standards/bisac_subject/index.html";
diff --git a/API/DTOs/OPDS/FeedEntry.cs b/API/DTOs/OPDS/FeedEntry.cs
index da8b53b74..838ebd124 100644
--- a/API/DTOs/OPDS/FeedEntry.cs
+++ b/API/DTOs/OPDS/FeedEntry.cs
@@ -5,7 +5,7 @@ using System.Xml.Serialization;
namespace API.DTOs.OPDS;
#nullable enable
-public class FeedEntry
+public sealed record FeedEntry
{
[XmlElement("updated")]
public string Updated { get; init; } = DateTime.UtcNow.ToString("s");
diff --git a/API/DTOs/OPDS/FeedEntryContent.cs b/API/DTOs/OPDS/FeedEntryContent.cs
index 3e95ce643..4de9b73bd 100644
--- a/API/DTOs/OPDS/FeedEntryContent.cs
+++ b/API/DTOs/OPDS/FeedEntryContent.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.OPDS;
-public class FeedEntryContent
+public sealed record FeedEntryContent
{
[XmlAttribute("type")]
public string Type = "text";
diff --git a/API/DTOs/OPDS/FeedLink.cs b/API/DTOs/OPDS/FeedLink.cs
index cff3b6736..28c55bbe8 100644
--- a/API/DTOs/OPDS/FeedLink.cs
+++ b/API/DTOs/OPDS/FeedLink.cs
@@ -3,7 +3,7 @@ using System.Xml.Serialization;
namespace API.DTOs.OPDS;
-public class FeedLink
+public sealed record FeedLink
{
[XmlIgnore]
public bool IsPageStream { get; set; }
diff --git a/API/DTOs/OPDS/OpenSearchDescription.cs b/API/DTOs/OPDS/OpenSearchDescription.cs
index cc8392a88..eba26572f 100644
--- a/API/DTOs/OPDS/OpenSearchDescription.cs
+++ b/API/DTOs/OPDS/OpenSearchDescription.cs
@@ -3,7 +3,7 @@
namespace API.DTOs.OPDS;
[XmlRoot("OpenSearchDescription", Namespace = "http://a9.com/-/spec/opensearch/1.1/")]
-public class OpenSearchDescription
+public sealed record OpenSearchDescription
{
///
/// Contains a brief human-readable title that identifies this search engine.
diff --git a/API/DTOs/OPDS/SearchLink.cs b/API/DTOs/OPDS/SearchLink.cs
index dba67f3bd..b4698c221 100644
--- a/API/DTOs/OPDS/SearchLink.cs
+++ b/API/DTOs/OPDS/SearchLink.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.OPDS;
-public class SearchLink
+public sealed record SearchLink
{
[XmlAttribute("type")]
public string Type { get; set; } = default!;
diff --git a/API/DTOs/Person/PersonDto.cs b/API/DTOs/Person/PersonDto.cs
index 511317f2a..db152e3b1 100644
--- a/API/DTOs/Person/PersonDto.cs
+++ b/API/DTOs/Person/PersonDto.cs
@@ -1,6 +1,6 @@
-using System.Runtime.Serialization;
+using System.Collections.Generic;
-namespace API.DTOs;
+namespace API.DTOs.Person;
#nullable enable
public class PersonDto
@@ -13,6 +13,7 @@ public class PersonDto
public string? SecondaryColor { get; set; }
public string? CoverImage { get; set; }
+ public List Aliases { get; set; } = [];
public string? Description { get; set; }
///
diff --git a/API/DTOs/Person/PersonMergeDto.cs b/API/DTOs/Person/PersonMergeDto.cs
new file mode 100644
index 000000000..b5dc23375
--- /dev/null
+++ b/API/DTOs/Person/PersonMergeDto.cs
@@ -0,0 +1,17 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace API.DTOs;
+
+public sealed record PersonMergeDto
+{
+ ///
+ /// The id of the person being merged into
+ ///
+ [Required]
+ public int DestId { get; init; }
+ ///
+ /// The id of the person being merged. This person will be removed, and become an alias of
+ ///
+ [Required]
+ public int SrcId { get; init; }
+}
diff --git a/API/DTOs/Person/UpdatePersonDto.cs b/API/DTOs/Person/UpdatePersonDto.cs
index d21fb7350..b43a45e88 100644
--- a/API/DTOs/Person/UpdatePersonDto.cs
+++ b/API/DTOs/Person/UpdatePersonDto.cs
@@ -1,9 +1,10 @@
-using System.ComponentModel.DataAnnotations;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
namespace API.DTOs;
#nullable enable
-public class UpdatePersonDto
+public sealed record UpdatePersonDto
{
[Required]
public int Id { get; init; }
@@ -11,6 +12,7 @@ public class UpdatePersonDto
public bool CoverImageLocked { get; set; }
[Required]
public string Name {get; set;}
+ public IList Aliases { get; set; } = [];
public string? Description { get; set; }
public int? AniListId { get; set; }
diff --git a/API/DTOs/Progress/FullProgressDto.cs b/API/DTOs/Progress/FullProgressDto.cs
index 7d0b47f60..4f97ab44a 100644
--- a/API/DTOs/Progress/FullProgressDto.cs
+++ b/API/DTOs/Progress/FullProgressDto.cs
@@ -5,7 +5,7 @@ namespace API.DTOs.Progress;
///
/// A full progress Record from the DB (not all data, only what's needed for API)
///
-public class FullProgressDto
+public sealed record FullProgressDto
{
public int Id { get; set; }
public int ChapterId { get; set; }
diff --git a/API/DTOs/Progress/ProgressDto.cs b/API/DTOs/Progress/ProgressDto.cs
index 9fc9010aa..0add848c5 100644
--- a/API/DTOs/Progress/ProgressDto.cs
+++ b/API/DTOs/Progress/ProgressDto.cs
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
namespace API.DTOs.Progress;
#nullable enable
-public class ProgressDto
+public sealed record ProgressDto
{
[Required]
public int VolumeId { get; set; }
diff --git a/API/DTOs/RatingDto.cs b/API/DTOs/RatingDto.cs
index 264d2d43c..101aa7ac5 100644
--- a/API/DTOs/RatingDto.cs
+++ b/API/DTOs/RatingDto.cs
@@ -1,14 +1,18 @@
-using API.Entities.Enums;
+using API.Entities;
+using API.Entities.Enums;
+using API.Entities.Metadata;
using API.Services.Plus;
namespace API.DTOs;
#nullable enable
-public class RatingDto
+public sealed record RatingDto
{
+
public int AverageScore { get; set; }
public int FavoriteCount { get; set; }
public ScrobbleProvider Provider { get; set; }
+ ///
public RatingAuthority Authority { get; set; } = RatingAuthority.User;
public string? ProviderUrl { get; set; }
}
diff --git a/API/DTOs/Reader/BookChapterItem.cs b/API/DTOs/Reader/BookChapterItem.cs
index dcfb7b904..892e82e27 100644
--- a/API/DTOs/Reader/BookChapterItem.cs
+++ b/API/DTOs/Reader/BookChapterItem.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Reader;
-public class BookChapterItem
+public sealed record BookChapterItem
{
///
/// Name of the Chapter
diff --git a/API/DTOs/Reader/BookInfoDto.cs b/API/DTOs/Reader/BookInfoDto.cs
index c379f71f8..2473cd5dc 100644
--- a/API/DTOs/Reader/BookInfoDto.cs
+++ b/API/DTOs/Reader/BookInfoDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Reader;
-public class BookInfoDto : IChapterInfoDto
+public sealed record BookInfoDto : IChapterInfoDto
{
public string BookTitle { get; set; } = default! ;
public int SeriesId { get; set; }
diff --git a/API/DTOs/Reader/BookmarkDto.cs b/API/DTOs/Reader/BookmarkDto.cs
index ef4cf3d6d..da18fc28e 100644
--- a/API/DTOs/Reader/BookmarkDto.cs
+++ b/API/DTOs/Reader/BookmarkDto.cs
@@ -3,7 +3,7 @@
namespace API.DTOs.Reader;
#nullable enable
-public class BookmarkDto
+public sealed record BookmarkDto
{
public int Id { get; set; }
[Required]
diff --git a/API/DTOs/Reader/BulkRemoveBookmarkForSeriesDto.cs b/API/DTOs/Reader/BulkRemoveBookmarkForSeriesDto.cs
index 7490f837c..51ccf5cc3 100644
--- a/API/DTOs/Reader/BulkRemoveBookmarkForSeriesDto.cs
+++ b/API/DTOs/Reader/BulkRemoveBookmarkForSeriesDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Reader;
-public class BulkRemoveBookmarkForSeriesDto
+public sealed record BulkRemoveBookmarkForSeriesDto
{
public ICollection SeriesIds { get; init; } = default!;
}
diff --git a/API/DTOs/Reader/ChapterInfoDto.cs b/API/DTOs/Reader/ChapterInfoDto.cs
index 4584a5830..4da08a31d 100644
--- a/API/DTOs/Reader/ChapterInfoDto.cs
+++ b/API/DTOs/Reader/ChapterInfoDto.cs
@@ -7,7 +7,7 @@ namespace API.DTOs.Reader;
///
/// Information about the Chapter for the Reader to render
///
-public class ChapterInfoDto : IChapterInfoDto
+public sealed record ChapterInfoDto : IChapterInfoDto
{
///
/// The Chapter Number
diff --git a/API/DTOs/Reader/CreatePersonalToCDto.cs b/API/DTOs/Reader/CreatePersonalToCDto.cs
index 3b80ece4a..95272ca58 100644
--- a/API/DTOs/Reader/CreatePersonalToCDto.cs
+++ b/API/DTOs/Reader/CreatePersonalToCDto.cs
@@ -1,7 +1,7 @@
namespace API.DTOs.Reader;
#nullable enable
-public class CreatePersonalToCDto
+public sealed record CreatePersonalToCDto
{
public required int ChapterId { get; set; }
public required int VolumeId { get; set; }
diff --git a/API/DTOs/Reader/FileDimensionDto.cs b/API/DTOs/Reader/FileDimensionDto.cs
index baee20dd0..7a7d2978f 100644
--- a/API/DTOs/Reader/FileDimensionDto.cs
+++ b/API/DTOs/Reader/FileDimensionDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Reader;
-public class FileDimensionDto
+public sealed record FileDimensionDto
{
public int Width { get; set; }
public int Height { get; set; }
diff --git a/API/DTOs/Reader/HourEstimateRangeDto.cs b/API/DTOs/Reader/HourEstimateRangeDto.cs
index 8c8bd11a9..3facf8e56 100644
--- a/API/DTOs/Reader/HourEstimateRangeDto.cs
+++ b/API/DTOs/Reader/HourEstimateRangeDto.cs
@@ -3,7 +3,7 @@
///
/// A range of time to read a selection (series, chapter, etc)
///
-public record HourEstimateRangeDto
+public sealed record HourEstimateRangeDto
{
///
/// Min hours to read the selection
diff --git a/API/DTOs/Reader/MarkMultipleSeriesAsReadDto.cs b/API/DTOs/Reader/MarkMultipleSeriesAsReadDto.cs
index 50187ec81..4c39f7d76 100644
--- a/API/DTOs/Reader/MarkMultipleSeriesAsReadDto.cs
+++ b/API/DTOs/Reader/MarkMultipleSeriesAsReadDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Reader;
-public class MarkMultipleSeriesAsReadDto
+public sealed record MarkMultipleSeriesAsReadDto
{
public IReadOnlyList SeriesIds { get; init; } = default!;
}
diff --git a/API/DTOs/Reader/MarkReadDto.cs b/API/DTOs/Reader/MarkReadDto.cs
index 9bf46a6d5..c6f7367c0 100644
--- a/API/DTOs/Reader/MarkReadDto.cs
+++ b/API/DTOs/Reader/MarkReadDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Reader;
-public class MarkReadDto
+public sealed record MarkReadDto
{
public int SeriesId { get; init; }
}
diff --git a/API/DTOs/Reader/MarkVolumeReadDto.cs b/API/DTOs/Reader/MarkVolumeReadDto.cs
index 47ffd2649..be95d2e98 100644
--- a/API/DTOs/Reader/MarkVolumeReadDto.cs
+++ b/API/DTOs/Reader/MarkVolumeReadDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Reader;
-public class MarkVolumeReadDto
+public sealed record MarkVolumeReadDto
{
public int SeriesId { get; init; }
public int VolumeId { get; init; }
diff --git a/API/DTOs/Reader/MarkVolumesReadDto.cs b/API/DTOs/Reader/MarkVolumesReadDto.cs
index ebe1cd76c..b07bfbc67 100644
--- a/API/DTOs/Reader/MarkVolumesReadDto.cs
+++ b/API/DTOs/Reader/MarkVolumesReadDto.cs
@@ -5,7 +5,7 @@ namespace API.DTOs.Reader;
///
/// This is used for bulk updating a set of volume and or chapters in one go
///
-public class MarkVolumesReadDto
+public sealed record MarkVolumesReadDto
{
public int SeriesId { get; set; }
///
diff --git a/API/DTOs/Reader/PersonalToCDto.cs b/API/DTOs/Reader/PersonalToCDto.cs
index 144ed561f..c979d9d78 100644
--- a/API/DTOs/Reader/PersonalToCDto.cs
+++ b/API/DTOs/Reader/PersonalToCDto.cs
@@ -2,7 +2,7 @@
#nullable enable
-public class PersonalToCDto
+public sealed record PersonalToCDto
{
public required int ChapterId { get; set; }
public required int PageNumber { get; set; }
diff --git a/API/DTOs/Reader/RemoveBookmarkForSeriesDto.cs b/API/DTOs/Reader/RemoveBookmarkForSeriesDto.cs
index ed6368a4f..ecbb744c8 100644
--- a/API/DTOs/Reader/RemoveBookmarkForSeriesDto.cs
+++ b/API/DTOs/Reader/RemoveBookmarkForSeriesDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Reader;
-public class RemoveBookmarkForSeriesDto
+public sealed record RemoveBookmarkForSeriesDto
{
public int SeriesId { get; init; }
}
diff --git a/API/DTOs/ReadingLists/CBL/CblBook.cs b/API/DTOs/ReadingLists/CBL/CblBook.cs
index 08930e208..d51795b8d 100644
--- a/API/DTOs/ReadingLists/CBL/CblBook.cs
+++ b/API/DTOs/ReadingLists/CBL/CblBook.cs
@@ -5,7 +5,7 @@ namespace API.DTOs.ReadingLists.CBL;
[XmlRoot(ElementName="Book")]
-public class CblBook
+public sealed record CblBook
{
[XmlAttribute("Series")]
public string Series { get; set; }
diff --git a/API/DTOs/ReadingLists/CBL/CblConflictsDto.cs b/API/DTOs/ReadingLists/CBL/CblConflictsDto.cs
index 70a002884..35234923f 100644
--- a/API/DTOs/ReadingLists/CBL/CblConflictsDto.cs
+++ b/API/DTOs/ReadingLists/CBL/CblConflictsDto.cs
@@ -3,7 +3,7 @@
namespace API.DTOs.ReadingLists.CBL;
-public class CblConflictQuestion
+public sealed record CblConflictQuestion
{
public string SeriesName { get; set; }
public IList LibrariesIds { get; set; }
diff --git a/API/DTOs/ReadingLists/CBL/CblImportSummary.cs b/API/DTOs/ReadingLists/CBL/CblImportSummary.cs
index 136a31aa8..b9716421e 100644
--- a/API/DTOs/ReadingLists/CBL/CblImportSummary.cs
+++ b/API/DTOs/ReadingLists/CBL/CblImportSummary.cs
@@ -75,7 +75,7 @@ public enum CblImportReason
InvalidFile = 9,
}
-public class CblBookResult
+public sealed record CblBookResult
{
///
/// Order in the CBL
@@ -114,7 +114,7 @@ public class CblBookResult
///
/// Represents the summary from the Import of a given CBL
///
-public class CblImportSummaryDto
+public sealed record CblImportSummaryDto
{
public string CblName { get; set; }
///
diff --git a/API/DTOs/ReadingLists/CBL/CblReadingList.cs b/API/DTOs/ReadingLists/CBL/CblReadingList.cs
index 001e6434b..15b349f42 100644
--- a/API/DTOs/ReadingLists/CBL/CblReadingList.cs
+++ b/API/DTOs/ReadingLists/CBL/CblReadingList.cs
@@ -5,7 +5,7 @@ namespace API.DTOs.ReadingLists.CBL;
[XmlRoot(ElementName="Books")]
-public class CblBooks
+public sealed record CblBooks
{
[XmlElement(ElementName="Book")]
public List Book { get; set; }
@@ -13,7 +13,7 @@ public class CblBooks
[XmlRoot(ElementName="ReadingList")]
-public class CblReadingList
+public sealed record CblReadingList
{
///
/// Name of the Reading List
diff --git a/API/DTOs/ReadingLists/CreateReadingListDto.cs b/API/DTOs/ReadingLists/CreateReadingListDto.cs
index 783253007..543215722 100644
--- a/API/DTOs/ReadingLists/CreateReadingListDto.cs
+++ b/API/DTOs/ReadingLists/CreateReadingListDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.ReadingLists;
-public class CreateReadingListDto
+public sealed record CreateReadingListDto
{
public string Title { get; init; } = default!;
}
diff --git a/API/DTOs/ReadingLists/DeleteReadingListsDto.cs b/API/DTOs/ReadingLists/DeleteReadingListsDto.cs
index 8417f8132..8ce92f939 100644
--- a/API/DTOs/ReadingLists/DeleteReadingListsDto.cs
+++ b/API/DTOs/ReadingLists/DeleteReadingListsDto.cs
@@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations;
namespace API.DTOs.ReadingLists;
-public class DeleteReadingListsDto
+public sealed record DeleteReadingListsDto
{
[Required]
public IList ReadingListIds { get; set; }
diff --git a/API/DTOs/ReadingLists/PromoteReadingListsDto.cs b/API/DTOs/ReadingLists/PromoteReadingListsDto.cs
index f64bbb5ca..8915274de 100644
--- a/API/DTOs/ReadingLists/PromoteReadingListsDto.cs
+++ b/API/DTOs/ReadingLists/PromoteReadingListsDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.ReadingLists;
-public class PromoteReadingListsDto
+public sealed record PromoteReadingListsDto
{
public IList ReadingListIds { get; init; }
public bool Promoted { get; init; }
diff --git a/API/DTOs/ReadingLists/ReadingListCast.cs b/API/DTOs/ReadingLists/ReadingListCast.cs
index 4532df7d5..855bb12b7 100644
--- a/API/DTOs/ReadingLists/ReadingListCast.cs
+++ b/API/DTOs/ReadingLists/ReadingListCast.cs
@@ -1,8 +1,9 @@
using System.Collections.Generic;
+using API.DTOs.Person;
namespace API.DTOs.ReadingLists;
-public class ReadingListCast
+public sealed record ReadingListCast
{
public ICollection Writers { get; set; } = [];
public ICollection CoverArtists { get; set; } = [];
diff --git a/API/DTOs/ReadingLists/ReadingListDto.cs b/API/DTOs/ReadingLists/ReadingListDto.cs
index 6508e7bd4..47a526411 100644
--- a/API/DTOs/ReadingLists/ReadingListDto.cs
+++ b/API/DTOs/ReadingLists/ReadingListDto.cs
@@ -5,7 +5,7 @@ using API.Entities.Interfaces;
namespace API.DTOs.ReadingLists;
#nullable enable
-public class ReadingListDto : IHasCoverImage
+public sealed record ReadingListDto : IHasCoverImage
{
public int Id { get; init; }
public string Title { get; set; } = default!;
@@ -20,8 +20,8 @@ public class ReadingListDto : IHasCoverImage
///
public string? CoverImage { get; set; } = string.Empty;
- public string PrimaryColor { get; set; } = string.Empty;
- public string SecondaryColor { get; set; } = string.Empty;
+ public string? PrimaryColor { get; set; } = string.Empty;
+ public string? SecondaryColor { get; set; } = string.Empty;
///
/// Number of Items in the Reading List
@@ -49,6 +49,11 @@ public class ReadingListDto : IHasCoverImage
///
public required AgeRating AgeRating { get; set; } = AgeRating.Unknown;
+ ///
+ /// Username of the User that owns (in the case of a promoted list)
+ ///
+ public string OwnerUserName { get; set; }
+
public void ResetColorScape()
{
PrimaryColor = string.Empty;
diff --git a/API/DTOs/ReadingLists/ReadingListInfoDto.cs b/API/DTOs/ReadingLists/ReadingListInfoDto.cs
index bd95b9226..64a305f43 100644
--- a/API/DTOs/ReadingLists/ReadingListInfoDto.cs
+++ b/API/DTOs/ReadingLists/ReadingListInfoDto.cs
@@ -3,7 +3,7 @@ using API.Entities.Interfaces;
namespace API.DTOs.ReadingLists;
-public class ReadingListInfoDto : IHasReadTimeEstimate
+public sealed record ReadingListInfoDto : IHasReadTimeEstimate
{
///
/// Total Pages across all Reading List Items
diff --git a/API/DTOs/ReadingLists/ReadingListItemDto.cs b/API/DTOs/ReadingLists/ReadingListItemDto.cs
index 4fca5360c..8edec14f1 100644
--- a/API/DTOs/ReadingLists/ReadingListItemDto.cs
+++ b/API/DTOs/ReadingLists/ReadingListItemDto.cs
@@ -4,7 +4,7 @@ using API.Entities.Enums;
namespace API.DTOs.ReadingLists;
#nullable enable
-public class ReadingListItemDto
+public sealed record ReadingListItemDto
{
public int Id { get; init; }
public int Order { get; init; }
diff --git a/API/DTOs/ReadingLists/UpdateReadingListByChapterDto.cs b/API/DTOs/ReadingLists/UpdateReadingListByChapterDto.cs
index 985f86ac0..6624c8a5c 100644
--- a/API/DTOs/ReadingLists/UpdateReadingListByChapterDto.cs
+++ b/API/DTOs/ReadingLists/UpdateReadingListByChapterDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.ReadingLists;
-public class UpdateReadingListByChapterDto
+public sealed record UpdateReadingListByChapterDto
{
public int ChapterId { get; init; }
public int SeriesId { get; init; }
diff --git a/API/DTOs/ReadingLists/UpdateReadingListByMultipleDto.cs b/API/DTOs/ReadingLists/UpdateReadingListByMultipleDto.cs
index 408963529..ba7625088 100644
--- a/API/DTOs/ReadingLists/UpdateReadingListByMultipleDto.cs
+++ b/API/DTOs/ReadingLists/UpdateReadingListByMultipleDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.ReadingLists;
-public class UpdateReadingListByMultipleDto
+public sealed record UpdateReadingListByMultipleDto
{
public int SeriesId { get; init; }
public int ReadingListId { get; init; }
diff --git a/API/DTOs/ReadingLists/UpdateReadingListByMultipleSeriesDto.cs b/API/DTOs/ReadingLists/UpdateReadingListByMultipleSeriesDto.cs
index f910e9c06..910a5744d 100644
--- a/API/DTOs/ReadingLists/UpdateReadingListByMultipleSeriesDto.cs
+++ b/API/DTOs/ReadingLists/UpdateReadingListByMultipleSeriesDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.ReadingLists;
-public class UpdateReadingListByMultipleSeriesDto
+public sealed record UpdateReadingListByMultipleSeriesDto
{
public int ReadingListId { get; init; }
public IReadOnlyList SeriesIds { get; init; } = default!;
diff --git a/API/DTOs/ReadingLists/UpdateReadingListBySeriesDto.cs b/API/DTOs/ReadingLists/UpdateReadingListBySeriesDto.cs
index 0590882bd..4bb4aa7bb 100644
--- a/API/DTOs/ReadingLists/UpdateReadingListBySeriesDto.cs
+++ b/API/DTOs/ReadingLists/UpdateReadingListBySeriesDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.ReadingLists;
-public class UpdateReadingListBySeriesDto
+public sealed record UpdateReadingListBySeriesDto
{
public int SeriesId { get; init; }
public int ReadingListId { get; init; }
diff --git a/API/DTOs/ReadingLists/UpdateReadingListByVolumeDto.cs b/API/DTOs/ReadingLists/UpdateReadingListByVolumeDto.cs
index f77c7d63a..422d1cc34 100644
--- a/API/DTOs/ReadingLists/UpdateReadingListByVolumeDto.cs
+++ b/API/DTOs/ReadingLists/UpdateReadingListByVolumeDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.ReadingLists;
-public class UpdateReadingListByVolumeDto
+public sealed record UpdateReadingListByVolumeDto
{
public int VolumeId { get; init; }
public int SeriesId { get; init; }
diff --git a/API/DTOs/ReadingLists/UpdateReadingListDto.cs b/API/DTOs/ReadingLists/UpdateReadingListDto.cs
index 6b590707a..de273d825 100644
--- a/API/DTOs/ReadingLists/UpdateReadingListDto.cs
+++ b/API/DTOs/ReadingLists/UpdateReadingListDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.ReadingLists;
-public class UpdateReadingListDto
+public sealed record UpdateReadingListDto
{
[Required]
public int ReadingListId { get; set; }
diff --git a/API/DTOs/ReadingLists/UpdateReadingListPosition.cs b/API/DTOs/ReadingLists/UpdateReadingListPosition.cs
index 3d0487144..04f2501a8 100644
--- a/API/DTOs/ReadingLists/UpdateReadingListPosition.cs
+++ b/API/DTOs/ReadingLists/UpdateReadingListPosition.cs
@@ -5,7 +5,7 @@ namespace API.DTOs.ReadingLists;
///
/// DTO for moving a reading list item to another position within the same list
///
-public class UpdateReadingListPosition
+public sealed record UpdateReadingListPosition
{
[Required] public int ReadingListId { get; set; }
[Required] public int ReadingListItemId { get; set; }
diff --git a/API/DTOs/Recommendation/ExternalSeriesDto.cs b/API/DTOs/Recommendation/ExternalSeriesDto.cs
index d393443af..752001a39 100644
--- a/API/DTOs/Recommendation/ExternalSeriesDto.cs
+++ b/API/DTOs/Recommendation/ExternalSeriesDto.cs
@@ -3,7 +3,7 @@
namespace API.DTOs.Recommendation;
#nullable enable
-public class ExternalSeriesDto
+public sealed record ExternalSeriesDto
{
public required string Name { get; set; }
public required string CoverUrl { get; set; }
diff --git a/API/DTOs/Recommendation/MetadataTagDto.cs b/API/DTOs/Recommendation/MetadataTagDto.cs
index b219dedc1..a7eb76284 100644
--- a/API/DTOs/Recommendation/MetadataTagDto.cs
+++ b/API/DTOs/Recommendation/MetadataTagDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Recommendation;
-public class MetadataTagDto
+public sealed record MetadataTagDto
{
public string Name { get; set; }
public string Description { get; private set; }
diff --git a/API/DTOs/Recommendation/RecommendationDto.cs b/API/DTOs/Recommendation/RecommendationDto.cs
index 679245a87..387661324 100644
--- a/API/DTOs/Recommendation/RecommendationDto.cs
+++ b/API/DTOs/Recommendation/RecommendationDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Recommendation;
-public class RecommendationDto
+public sealed record RecommendationDto
{
public IList OwnedSeries { get; set; } = new List();
public IList ExternalSeries { get; set; } = new List();
diff --git a/API/DTOs/Recommendation/SeriesStaffDto.cs b/API/DTOs/Recommendation/SeriesStaffDto.cs
index e4c6f6423..e074e8625 100644
--- a/API/DTOs/Recommendation/SeriesStaffDto.cs
+++ b/API/DTOs/Recommendation/SeriesStaffDto.cs
@@ -1,7 +1,7 @@
namespace API.DTOs.Recommendation;
#nullable enable
-public class SeriesStaffDto
+public sealed record SeriesStaffDto
{
public required string Name { get; set; }
public string? FirstName { get; set; }
diff --git a/API/DTOs/RefreshSeriesDto.cs b/API/DTOs/RefreshSeriesDto.cs
index 0e94fc44b..ad26afba2 100644
--- a/API/DTOs/RefreshSeriesDto.cs
+++ b/API/DTOs/RefreshSeriesDto.cs
@@ -3,7 +3,7 @@
///
/// Used for running some task against a Series.
///
-public class RefreshSeriesDto
+public sealed record RefreshSeriesDto
{
///
/// Library Id series belongs to
diff --git a/API/DTOs/RegisterDto.cs b/API/DTOs/RegisterDto.cs
index 2d4d3b77f..e117af872 100644
--- a/API/DTOs/RegisterDto.cs
+++ b/API/DTOs/RegisterDto.cs
@@ -3,7 +3,7 @@
namespace API.DTOs;
#nullable enable
-public class RegisterDto
+public sealed record RegisterDto
{
[Required]
public string Username { get; init; } = default!;
diff --git a/API/DTOs/ScanFolderDto.cs b/API/DTOs/ScanFolderDto.cs
index 684de909e..141f7f0b5 100644
--- a/API/DTOs/ScanFolderDto.cs
+++ b/API/DTOs/ScanFolderDto.cs
@@ -3,7 +3,7 @@
///
/// DTO for requesting a folder to be scanned
///
-public class ScanFolderDto
+public sealed record ScanFolderDto
{
///
/// Api key for a user with Admin permissions
diff --git a/API/DTOs/Scrobbling/MalUserInfoDto.cs b/API/DTOs/Scrobbling/MalUserInfoDto.cs
index 407639e2a..b6fefc053 100644
--- a/API/DTOs/Scrobbling/MalUserInfoDto.cs
+++ b/API/DTOs/Scrobbling/MalUserInfoDto.cs
@@ -3,7 +3,7 @@
///
/// Information about a User's MAL connection
///
-public class MalUserInfoDto
+public sealed record MalUserInfoDto
{
public required string Username { get; set; }
///
diff --git a/API/DTOs/Scrobbling/MediaRecommendationDto.cs b/API/DTOs/Scrobbling/MediaRecommendationDto.cs
index 3f565296b..476d77279 100644
--- a/API/DTOs/Scrobbling/MediaRecommendationDto.cs
+++ b/API/DTOs/Scrobbling/MediaRecommendationDto.cs
@@ -4,7 +4,7 @@ using API.Services.Plus;
namespace API.DTOs.Scrobbling;
#nullable enable
-public record MediaRecommendationDto
+public sealed record MediaRecommendationDto
{
public int Rating { get; set; }
public IEnumerable RecommendationNames { get; set; } = null!;
diff --git a/API/DTOs/Scrobbling/PlusSeriesDto.cs b/API/DTOs/Scrobbling/PlusSeriesDto.cs
index dca9aca92..4d0ef4ea1 100644
--- a/API/DTOs/Scrobbling/PlusSeriesDto.cs
+++ b/API/DTOs/Scrobbling/PlusSeriesDto.cs
@@ -4,7 +4,7 @@
///
/// Represents information about a potential Series for Kavita+
///
-public record PlusSeriesRequestDto
+public sealed record PlusSeriesRequestDto
{
public int? AniListId { get; set; }
public long? MalId { get; set; }
diff --git a/API/DTOs/Scrobbling/ScrobbleDto.cs b/API/DTOs/Scrobbling/ScrobbleDto.cs
index e8420e785..b90441059 100644
--- a/API/DTOs/Scrobbling/ScrobbleDto.cs
+++ b/API/DTOs/Scrobbling/ScrobbleDto.cs
@@ -36,7 +36,7 @@ public enum PlusMediaFormat
}
-public class ScrobbleDto
+public sealed record ScrobbleDto
{
///
/// User's access token to allow us to talk on their behalf
diff --git a/API/DTOs/Scrobbling/ScrobbleErrorDto.cs b/API/DTOs/Scrobbling/ScrobbleErrorDto.cs
index da85f28f1..7caaad1ca 100644
--- a/API/DTOs/Scrobbling/ScrobbleErrorDto.cs
+++ b/API/DTOs/Scrobbling/ScrobbleErrorDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Scrobbling;
-public class ScrobbleErrorDto
+public sealed record ScrobbleErrorDto
{
///
/// Developer defined string
diff --git a/API/DTOs/Scrobbling/ScrobbleEventDto.cs b/API/DTOs/Scrobbling/ScrobbleEventDto.cs
index b62c87866..562d923ff 100644
--- a/API/DTOs/Scrobbling/ScrobbleEventDto.cs
+++ b/API/DTOs/Scrobbling/ScrobbleEventDto.cs
@@ -3,8 +3,9 @@
namespace API.DTOs.Scrobbling;
#nullable enable
-public class ScrobbleEventDto
+public sealed record ScrobbleEventDto
{
+ public long Id { get; init; }
public string SeriesName { get; set; }
public int SeriesId { get; set; }
public int LibraryId { get; set; }
diff --git a/API/DTOs/Scrobbling/ScrobbleHoldDto.cs b/API/DTOs/Scrobbling/ScrobbleHoldDto.cs
index dcfe7726f..3e09e4799 100644
--- a/API/DTOs/Scrobbling/ScrobbleHoldDto.cs
+++ b/API/DTOs/Scrobbling/ScrobbleHoldDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Scrobbling;
-public class ScrobbleHoldDto
+public sealed record ScrobbleHoldDto
{
public string SeriesName { get; set; }
public int SeriesId { get; set; }
diff --git a/API/DTOs/Scrobbling/ScrobbleResponseDto.cs b/API/DTOs/Scrobbling/ScrobbleResponseDto.cs
index a63e955d7..ad66729d0 100644
--- a/API/DTOs/Scrobbling/ScrobbleResponseDto.cs
+++ b/API/DTOs/Scrobbling/ScrobbleResponseDto.cs
@@ -4,9 +4,10 @@
///
/// Response from Kavita+ Scrobble API
///
-public class ScrobbleResponseDto
+public sealed record ScrobbleResponseDto
{
public bool Successful { get; set; }
public string? ErrorMessage { get; set; }
+ public string? ExtraInformation {get; set;}
public int RateLeft { get; set; }
}
diff --git a/API/DTOs/Search/BookmarkSearchResultDto.cs b/API/DTOs/Search/BookmarkSearchResultDto.cs
index 5d53add1f..c11d2a2b8 100644
--- a/API/DTOs/Search/BookmarkSearchResultDto.cs
+++ b/API/DTOs/Search/BookmarkSearchResultDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Search;
-public class BookmarkSearchResultDto
+public sealed record BookmarkSearchResultDto
{
public int LibraryId { get; set; }
public int VolumeId { get; set; }
diff --git a/API/DTOs/Search/SearchResultDto.cs b/API/DTOs/Search/SearchResultDto.cs
index 6fcae3b5d..c497b55dd 100644
--- a/API/DTOs/Search/SearchResultDto.cs
+++ b/API/DTOs/Search/SearchResultDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Search;
-public class SearchResultDto
+public sealed record SearchResultDto
{
public int SeriesId { get; init; }
public string Name { get; init; } = default!;
diff --git a/API/DTOs/Search/SearchResultGroupDto.cs b/API/DTOs/Search/SearchResultGroupDto.cs
index f7a622664..11c4bdc08 100644
--- a/API/DTOs/Search/SearchResultGroupDto.cs
+++ b/API/DTOs/Search/SearchResultGroupDto.cs
@@ -2,6 +2,7 @@
using API.DTOs.Collection;
using API.DTOs.CollectionTags;
using API.DTOs.Metadata;
+using API.DTOs.Person;
using API.DTOs.Reader;
using API.DTOs.ReadingLists;
@@ -10,7 +11,7 @@ namespace API.DTOs.Search;
///
/// Represents all Search results for a query
///
-public class SearchResultGroupDto
+public sealed record SearchResultGroupDto
{
public IEnumerable Libraries { get; set; } = default!;
public IEnumerable Series { get; set; } = default!;
diff --git a/API/DTOs/SeriesByIdsDto.cs b/API/DTOs/SeriesByIdsDto.cs
index 12e13d96f..cb4c52b1e 100644
--- a/API/DTOs/SeriesByIdsDto.cs
+++ b/API/DTOs/SeriesByIdsDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs;
-public class SeriesByIdsDto
+public sealed record SeriesByIdsDto
{
public int[] SeriesIds { get; init; } = default!;
}
diff --git a/API/DTOs/SeriesDetail/NextExpectedChapterDto.cs b/API/DTOs/SeriesDetail/NextExpectedChapterDto.cs
index 0f1a8eb4b..1bea81c84 100644
--- a/API/DTOs/SeriesDetail/NextExpectedChapterDto.cs
+++ b/API/DTOs/SeriesDetail/NextExpectedChapterDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.SeriesDetail;
-public class NextExpectedChapterDto
+public sealed record NextExpectedChapterDto
{
public float ChapterNumber { get; set; }
public float VolumeNumber { get; set; }
diff --git a/API/DTOs/SeriesDetail/RelatedSeriesDto.cs b/API/DTOs/SeriesDetail/RelatedSeriesDto.cs
index 29b9eb263..a186dc295 100644
--- a/API/DTOs/SeriesDetail/RelatedSeriesDto.cs
+++ b/API/DTOs/SeriesDetail/RelatedSeriesDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.SeriesDetail;
-public class RelatedSeriesDto
+public sealed record RelatedSeriesDto
{
///
/// The parent relationship Series
diff --git a/API/DTOs/SeriesDetail/SeriesDetailDto.cs b/API/DTOs/SeriesDetail/SeriesDetailDto.cs
index 65d657c67..c4f15552d 100644
--- a/API/DTOs/SeriesDetail/SeriesDetailDto.cs
+++ b/API/DTOs/SeriesDetail/SeriesDetailDto.cs
@@ -7,7 +7,7 @@ namespace API.DTOs.SeriesDetail;
/// This is a special DTO for a UI page in Kavita. This performs sorting and grouping and returns exactly what UI requires for layout.
/// This is subject to change, do not rely on this Data model.
///
-public class SeriesDetailDto
+public sealed record SeriesDetailDto
{
///
/// Specials for the Series. These will have their title and range cleaned to remove the special marker and prepare
diff --git a/API/DTOs/SeriesDetail/SeriesDetailPlusDto.cs b/API/DTOs/SeriesDetail/SeriesDetailPlusDto.cs
index 76e77ae2c..95f5f39bd 100644
--- a/API/DTOs/SeriesDetail/SeriesDetailPlusDto.cs
+++ b/API/DTOs/SeriesDetail/SeriesDetailPlusDto.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using API.DTOs.KavitaPlus.Metadata;
using API.DTOs.Recommendation;
namespace API.DTOs.SeriesDetail;
@@ -8,7 +9,7 @@ namespace API.DTOs.SeriesDetail;
/// All the data from Kavita+ for Series Detail
///
/// This is what the UI sees, not what the API sends back
-public class SeriesDetailPlusDto
+public sealed record SeriesDetailPlusDto
{
public RecommendationDto? Recommendations { get; set; }
public IEnumerable Reviews { get; set; }
diff --git a/API/DTOs/SeriesDetail/UpdateRelatedSeriesDto.cs b/API/DTOs/SeriesDetail/UpdateRelatedSeriesDto.cs
index f19ad9ca8..a1bb2057e 100644
--- a/API/DTOs/SeriesDetail/UpdateRelatedSeriesDto.cs
+++ b/API/DTOs/SeriesDetail/UpdateRelatedSeriesDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.SeriesDetail;
-public class UpdateRelatedSeriesDto
+public sealed record UpdateRelatedSeriesDto
{
public int SeriesId { get; set; }
public IList Adaptations { get; set; } = default!;
diff --git a/API/DTOs/SeriesDetail/UpdateUserReviewDto.cs b/API/DTOs/SeriesDetail/UpdateUserReviewDto.cs
index adff04d6c..7af9441c1 100644
--- a/API/DTOs/SeriesDetail/UpdateUserReviewDto.cs
+++ b/API/DTOs/SeriesDetail/UpdateUserReviewDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.SeriesDetail;
#nullable enable
-public class UpdateUserReviewDto
+public sealed record UpdateUserReviewDto
{
public int SeriesId { get; set; }
public int? ChapterId { get; set; }
diff --git a/API/DTOs/SeriesDetail/UserReviewDto.cs b/API/DTOs/SeriesDetail/UserReviewDto.cs
index c8340a40a..9e05bbd65 100644
--- a/API/DTOs/SeriesDetail/UserReviewDto.cs
+++ b/API/DTOs/SeriesDetail/UserReviewDto.cs
@@ -9,7 +9,7 @@ namespace API.DTOs.SeriesDetail;
/// Represents a User Review for a given Series
///
/// The user does not need to be a Kavita user
-public class UserReviewDto
+public sealed record UserReviewDto
{
///
/// A tagline for the review
diff --git a/API/DTOs/SeriesDto.cs b/API/DTOs/SeriesDto.cs
index 6aa1ecefd..8a49d4c05 100644
--- a/API/DTOs/SeriesDto.cs
+++ b/API/DTOs/SeriesDto.cs
@@ -5,14 +5,21 @@ using API.Entities.Interfaces;
namespace API.DTOs;
#nullable enable
-public class SeriesDto : IHasReadTimeEstimate, IHasCoverImage
+public sealed record SeriesDto : IHasReadTimeEstimate, IHasCoverImage
{
+ ///
public int Id { get; init; }
+ ///
public string? Name { get; init; }
+ ///
public string? OriginalName { get; init; }
+ ///
public string? LocalizedName { get; init; }
+ ///
public string? SortName { get; init; }
+ ///
public int Pages { get; init; }
+ ///
public bool CoverImageLocked { get; set; }
///
/// Sum of pages read from linked Volumes. Calculated at API-time.
@@ -22,9 +29,7 @@ public class SeriesDto : IHasReadTimeEstimate, IHasCoverImage
/// DateTime representing last time the series was Read. Calculated at API-time.
///
public DateTime LatestReadDate { get; set; }
- ///
- /// DateTime representing last time a chapter was added to the Series
- ///
+ ///
public DateTime LastChapterAdded { get; set; }
///
/// Rating from logged in user. Calculated at API-time.
@@ -35,17 +40,19 @@ public class SeriesDto : IHasReadTimeEstimate, IHasCoverImage
///
public bool HasUserRated { get; set; }
+ ///
public MangaFormat Format { get; set; }
+ ///
public DateTime Created { get; set; }
- public bool NameLocked { get; set; }
+ ///
public bool SortNameLocked { get; set; }
+ ///
public bool LocalizedNameLocked { get; set; }
- ///
- /// Total number of words for the series. Only applies to epubs.
- ///
+ ///
public long WordCount { get; set; }
+ ///
public int LibraryId { get; set; }
public string LibraryName { get; set; } = default!;
///
@@ -54,33 +61,25 @@ public class SeriesDto : IHasReadTimeEstimate, IHasCoverImage
public int MaxHoursToRead { get; set; }
///
public float AvgHoursToRead { get; set; }
- ///
- /// The highest level folder for this Series
- ///
+ ///
public string FolderPath { get; set; } = default!;
- ///
- /// Lowest path (that is under library root) that contains all files for the series.
- ///
- /// must be used before setting
+ ///
public string? LowestFolderPath { get; set; }
- ///
- /// The last time the folder for this series was scanned
- ///
+ ///
public DateTime LastFolderScanned { get; set; }
#region KavitaPlus
- ///
- /// Do not match the series with any external Metadata service. This will automatically opt it out of scrobbling.
- ///
+ ///
public bool DontMatch { get; set; }
- ///
- /// If the series was unable to match, it will be blacklisted until a manual metadata match overrides it
- ///
+ ///
public bool IsBlacklisted { get; set; }
#endregion
+ ///
public string? CoverImage { get; set; }
- public string PrimaryColor { get; set; } = string.Empty;
- public string SecondaryColor { get; set; } = string.Empty;
+ ///
+ public string? PrimaryColor { get; set; } = string.Empty;
+ ///
+ public string? SecondaryColor { get; set; } = string.Empty;
public void ResetColorScape()
{
diff --git a/API/DTOs/SeriesMetadataDto.cs b/API/DTOs/SeriesMetadataDto.cs
index 3f344dff5..fa745148e 100644
--- a/API/DTOs/SeriesMetadataDto.cs
+++ b/API/DTOs/SeriesMetadataDto.cs
@@ -1,10 +1,11 @@
using System.Collections.Generic;
using API.DTOs.Metadata;
+using API.DTOs.Person;
using API.Entities.Enums;
namespace API.DTOs;
-public class SeriesMetadataDto
+public sealed record SeriesMetadataDto
{
public int Id { get; set; }
public string Summary { get; set; } = string.Empty;
diff --git a/API/DTOs/Settings/SMTPConfigDto.cs b/API/DTOs/Settings/SMTPConfigDto.cs
index 07cc58cb8..c14140062 100644
--- a/API/DTOs/Settings/SMTPConfigDto.cs
+++ b/API/DTOs/Settings/SMTPConfigDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Settings;
-public class SmtpConfigDto
+public sealed record SmtpConfigDto
{
public string SenderAddress { get; set; } = string.Empty;
public string SenderDisplayName { get; set; } = string.Empty;
diff --git a/API/DTOs/Settings/ServerSettingDTO.cs b/API/DTOs/Settings/ServerSettingDTO.cs
index 78db88d7d..372042250 100644
--- a/API/DTOs/Settings/ServerSettingDTO.cs
+++ b/API/DTOs/Settings/ServerSettingDTO.cs
@@ -6,7 +6,7 @@ using API.Services;
namespace API.DTOs.Settings;
#nullable enable
-public class ServerSettingDto
+public sealed record ServerSettingDto
{
public string CacheDirectory { get; set; } = default!;
diff --git a/API/DTOs/SideNav/BulkUpdateSideNavStreamVisibilityDto.cs b/API/DTOs/SideNav/BulkUpdateSideNavStreamVisibilityDto.cs
index 1b081913d..ae1d927a9 100644
--- a/API/DTOs/SideNav/BulkUpdateSideNavStreamVisibilityDto.cs
+++ b/API/DTOs/SideNav/BulkUpdateSideNavStreamVisibilityDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.SideNav;
-public class BulkUpdateSideNavStreamVisibilityDto
+public sealed record BulkUpdateSideNavStreamVisibilityDto
{
public required IList Ids { get; set; }
public required bool Visibility { get; set; }
diff --git a/API/DTOs/SideNav/ExternalSourceDto.cs b/API/DTOs/SideNav/ExternalSourceDto.cs
index e9ae03066..382124e8a 100644
--- a/API/DTOs/SideNav/ExternalSourceDto.cs
+++ b/API/DTOs/SideNav/ExternalSourceDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.SideNav;
-public class ExternalSourceDto
+public sealed record ExternalSourceDto
{
public required int Id { get; set; } = 0;
public required string Name { get; set; }
diff --git a/API/DTOs/SideNav/SideNavStreamDto.cs b/API/DTOs/SideNav/SideNavStreamDto.cs
index fdef82a08..f4c196244 100644
--- a/API/DTOs/SideNav/SideNavStreamDto.cs
+++ b/API/DTOs/SideNav/SideNavStreamDto.cs
@@ -4,7 +4,7 @@ using API.Entities.Enums;
namespace API.DTOs.SideNav;
#nullable enable
-public class SideNavStreamDto
+public sealed record SideNavStreamDto
{
public int Id { get; set; }
public required string Name { get; set; }
diff --git a/API/DTOs/Statistics/Count.cs b/API/DTOs/Statistics/Count.cs
index 411b44897..1577e682c 100644
--- a/API/DTOs/Statistics/Count.cs
+++ b/API/DTOs/Statistics/Count.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Statistics;
-public class StatCount : ICount
+public sealed record StatCount : ICount
{
public T Value { get; set; } = default!;
public long Count { get; set; }
diff --git a/API/DTOs/Statistics/FileExtensionBreakdownDto.cs b/API/DTOs/Statistics/FileExtensionBreakdownDto.cs
index 1f122d992..7a248caef 100644
--- a/API/DTOs/Statistics/FileExtensionBreakdownDto.cs
+++ b/API/DTOs/Statistics/FileExtensionBreakdownDto.cs
@@ -4,7 +4,7 @@ using API.Entities.Enums;
namespace API.DTOs.Statistics;
#nullable enable
-public class FileExtensionDto
+public sealed record FileExtensionDto
{
public string? Extension { get; set; }
public MangaFormat Format { get; set; }
@@ -12,7 +12,7 @@ public class FileExtensionDto
public long TotalFiles { get; set; }
}
-public class FileExtensionBreakdownDto
+public sealed record FileExtensionBreakdownDto
{
///
/// Total bytes for all files
diff --git a/API/DTOs/Statistics/PagesReadOnADayCount.cs b/API/DTOs/Statistics/PagesReadOnADayCount.cs
index b1a6bb1ea..fc56d9cc0 100644
--- a/API/DTOs/Statistics/PagesReadOnADayCount.cs
+++ b/API/DTOs/Statistics/PagesReadOnADayCount.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Statistics;
-public class PagesReadOnADayCount : ICount
+public sealed record PagesReadOnADayCount : ICount
{
///
/// The day of the readings
diff --git a/API/DTOs/Statistics/ReadHistoryEvent.cs b/API/DTOs/Statistics/ReadHistoryEvent.cs
index 496148789..5d8262aef 100644
--- a/API/DTOs/Statistics/ReadHistoryEvent.cs
+++ b/API/DTOs/Statistics/ReadHistoryEvent.cs
@@ -6,7 +6,7 @@ namespace API.DTOs.Statistics;
///
/// Represents a single User's reading event
///
-public class ReadHistoryEvent
+public sealed record ReadHistoryEvent
{
public int UserId { get; set; }
public required string? UserName { get; set; } = default!;
diff --git a/API/DTOs/Statistics/ServerStatisticsDto.cs b/API/DTOs/Statistics/ServerStatisticsDto.cs
index 57fd5abce..3d22d9a56 100644
--- a/API/DTOs/Statistics/ServerStatisticsDto.cs
+++ b/API/DTOs/Statistics/ServerStatisticsDto.cs
@@ -3,7 +3,7 @@
namespace API.DTOs.Statistics;
#nullable enable
-public class ServerStatisticsDto
+public sealed record ServerStatisticsDto
{
public long ChapterCount { get; set; }
public long VolumeCount { get; set; }
diff --git a/API/DTOs/Statistics/TopReadsDto.cs b/API/DTOs/Statistics/TopReadsDto.cs
index 806360533..d11594dca 100644
--- a/API/DTOs/Statistics/TopReadsDto.cs
+++ b/API/DTOs/Statistics/TopReadsDto.cs
@@ -1,7 +1,7 @@
namespace API.DTOs.Statistics;
#nullable enable
-public class TopReadDto
+public sealed record TopReadDto
{
public int UserId { get; set; }
public string? Username { get; set; } = default!;
diff --git a/API/DTOs/Statistics/UserReadStatistics.cs b/API/DTOs/Statistics/UserReadStatistics.cs
index 5da4b491e..5c6935c6e 100644
--- a/API/DTOs/Statistics/UserReadStatistics.cs
+++ b/API/DTOs/Statistics/UserReadStatistics.cs
@@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace API.DTOs.Statistics;
#nullable enable
-public class UserReadStatistics
+public sealed record UserReadStatistics
{
///
/// Total number of pages read
diff --git a/API/DTOs/Stats/FileExtensionExportDto.cs b/API/DTOs/Stats/FileExtensionExportDto.cs
index 6ed554d75..e881960a5 100644
--- a/API/DTOs/Stats/FileExtensionExportDto.cs
+++ b/API/DTOs/Stats/FileExtensionExportDto.cs
@@ -5,7 +5,7 @@ namespace API.DTOs.Stats;
///
/// Excel export for File Extension Report
///
-public class FileExtensionExportDto
+public sealed record FileExtensionExportDto
{
[Name("Path")]
public string FilePath { get; set; }
diff --git a/API/DTOs/Stats/ServerInfoSlimDto.cs b/API/DTOs/Stats/ServerInfoSlimDto.cs
index 0b47fa2f3..f1abb2e1d 100644
--- a/API/DTOs/Stats/ServerInfoSlimDto.cs
+++ b/API/DTOs/Stats/ServerInfoSlimDto.cs
@@ -6,7 +6,7 @@ namespace API.DTOs.Stats;
///
/// This is just for the Server tab on UI
///
-public class ServerInfoSlimDto
+public sealed record ServerInfoSlimDto
{
///
/// Unique Id that represents a unique install
diff --git a/API/DTOs/Stats/V3/LibraryStatV3.cs b/API/DTOs/Stats/V3/LibraryStatV3.cs
index 51af34b58..33ac86d2b 100644
--- a/API/DTOs/Stats/V3/LibraryStatV3.cs
+++ b/API/DTOs/Stats/V3/LibraryStatV3.cs
@@ -4,7 +4,7 @@ using API.Entities.Enums;
namespace API.DTOs.Stats.V3;
-public class LibraryStatV3
+public sealed record LibraryStatV3
{
public bool IncludeInDashboard { get; set; }
public bool IncludeInSearch { get; set; }
diff --git a/API/DTOs/Stats/V3/RelationshipStatV3.cs b/API/DTOs/Stats/V3/RelationshipStatV3.cs
index e8e1e7440..37b63cb9a 100644
--- a/API/DTOs/Stats/V3/RelationshipStatV3.cs
+++ b/API/DTOs/Stats/V3/RelationshipStatV3.cs
@@ -5,7 +5,7 @@ namespace API.DTOs.Stats.V3;
///
/// KavitaStats - Information about Series Relationships
///
-public class RelationshipStatV3
+public sealed record RelationshipStatV3
{
public int Count { get; set; }
public RelationKind Relationship { get; set; }
diff --git a/API/DTOs/Stats/V3/ServerInfoV3Dto.cs b/API/DTOs/Stats/V3/ServerInfoV3Dto.cs
index 0bf95403f..8ed3079f5 100644
--- a/API/DTOs/Stats/V3/ServerInfoV3Dto.cs
+++ b/API/DTOs/Stats/V3/ServerInfoV3Dto.cs
@@ -7,7 +7,7 @@ namespace API.DTOs.Stats.V3;
///
/// Represents information about a Kavita Installation for Kavita Stats v3 API
///
-public class ServerInfoV3Dto
+public sealed record ServerInfoV3Dto
{
///
/// Unique Id that represents a unique install
diff --git a/API/DTOs/Stats/V3/UserStatV3.cs b/API/DTOs/Stats/V3/UserStatV3.cs
index 7f4e080ba..450a2e409 100644
--- a/API/DTOs/Stats/V3/UserStatV3.cs
+++ b/API/DTOs/Stats/V3/UserStatV3.cs
@@ -5,7 +5,7 @@ using API.Entities.Enums.Device;
namespace API.DTOs.Stats.V3;
-public class UserStatV3
+public sealed record UserStatV3
{
public AgeRestriction AgeRestriction { get; set; }
///
diff --git a/API/DTOs/System/DirectoryDto.cs b/API/DTOs/System/DirectoryDto.cs
index e6e94f4e4..3b1408f7f 100644
--- a/API/DTOs/System/DirectoryDto.cs
+++ b/API/DTOs/System/DirectoryDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.System;
-public class DirectoryDto
+public sealed record DirectoryDto
{
///
/// Name of the directory
diff --git a/API/DTOs/Theme/ColorScapeDto.cs b/API/DTOs/Theme/ColorScapeDto.cs
index 066e87d84..2ebd96e2b 100644
--- a/API/DTOs/Theme/ColorScapeDto.cs
+++ b/API/DTOs/Theme/ColorScapeDto.cs
@@ -4,7 +4,7 @@
///
/// A set of colors for the color scape system in the UI
///
-public class ColorScapeDto
+public sealed record ColorScapeDto
{
public string? Primary { get; set; }
public string? Secondary { get; set; }
diff --git a/API/DTOs/Theme/DownloadableSiteThemeDto.cs b/API/DTOs/Theme/DownloadableSiteThemeDto.cs
index dbcedfe61..b27263d92 100644
--- a/API/DTOs/Theme/DownloadableSiteThemeDto.cs
+++ b/API/DTOs/Theme/DownloadableSiteThemeDto.cs
@@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace API.DTOs.Theme;
-public class DownloadableSiteThemeDto
+public sealed record DownloadableSiteThemeDto
{
///
/// Theme Name
diff --git a/API/DTOs/Theme/SiteThemeDto.cs b/API/DTOs/Theme/SiteThemeDto.cs
index eb2a14904..7ae8369e9 100644
--- a/API/DTOs/Theme/SiteThemeDto.cs
+++ b/API/DTOs/Theme/SiteThemeDto.cs
@@ -7,7 +7,7 @@ namespace API.DTOs.Theme;
///
/// Represents a set of css overrides the user can upload to Kavita and will load into webui
///
-public class SiteThemeDto
+public sealed record SiteThemeDto
{
public int Id { get; set; }
///
diff --git a/API/DTOs/Theme/UpdateDefaultThemeDto.cs b/API/DTOs/Theme/UpdateDefaultThemeDto.cs
index 0f2b129f3..aac0858c3 100644
--- a/API/DTOs/Theme/UpdateDefaultThemeDto.cs
+++ b/API/DTOs/Theme/UpdateDefaultThemeDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Theme;
-public class UpdateDefaultThemeDto
+public sealed record UpdateDefaultThemeDto
{
public int ThemeId { get; set; }
}
diff --git a/API/DTOs/Update/UpdateNotificationDto.cs b/API/DTOs/Update/UpdateNotificationDto.cs
index 2f9550746..b535684f0 100644
--- a/API/DTOs/Update/UpdateNotificationDto.cs
+++ b/API/DTOs/Update/UpdateNotificationDto.cs
@@ -6,7 +6,7 @@ namespace API.DTOs.Update;
///
/// Update Notification denoting a new release available for user to update to
///
-public class UpdateNotificationDto
+public sealed record UpdateNotificationDto
{
///
/// Current installed Version
diff --git a/API/DTOs/UpdateChapterDto.cs b/API/DTOs/UpdateChapterDto.cs
index 2ca0a12a9..9ead8adc8 100644
--- a/API/DTOs/UpdateChapterDto.cs
+++ b/API/DTOs/UpdateChapterDto.cs
@@ -1,11 +1,12 @@
using System;
using System.Collections.Generic;
using API.DTOs.Metadata;
+using API.DTOs.Person;
using API.Entities.Enums;
namespace API.DTOs;
-public class UpdateChapterDto
+public sealed record UpdateChapterDto
{
public int Id { get; init; }
public string Summary { get; set; } = string.Empty;
diff --git a/API/DTOs/UpdateLibraryDto.cs b/API/DTOs/UpdateLibraryDto.cs
index de02f304d..d7f314208 100644
--- a/API/DTOs/UpdateLibraryDto.cs
+++ b/API/DTOs/UpdateLibraryDto.cs
@@ -4,7 +4,7 @@ using API.Entities.Enums;
namespace API.DTOs;
-public class UpdateLibraryDto
+public sealed record UpdateLibraryDto
{
[Required]
public int Id { get; init; }
@@ -28,6 +28,10 @@ public class UpdateLibraryDto
public bool AllowScrobbling { get; init; }
[Required]
public bool AllowMetadataMatching { get; init; }
+ [Required]
+ public bool EnableMetadata { get; init; }
+ [Required]
+ public bool RemovePrefixForSortName { get; init; }
///
/// What types of files to allow the scanner to pickup
///
diff --git a/API/DTOs/UpdateLibraryForUserDto.cs b/API/DTOs/UpdateLibraryForUserDto.cs
index c90b697e2..4ce8d0df8 100644
--- a/API/DTOs/UpdateLibraryForUserDto.cs
+++ b/API/DTOs/UpdateLibraryForUserDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs;
-public class UpdateLibraryForUserDto
+public sealed record UpdateLibraryForUserDto
{
public required string Username { get; init; }
public required IEnumerable SelectedLibraries { get; init; } = new List();
diff --git a/API/DTOs/UpdateRBSDto.cs b/API/DTOs/UpdateRBSDto.cs
index a7e0c3fc9..fa8bb78f9 100644
--- a/API/DTOs/UpdateRBSDto.cs
+++ b/API/DTOs/UpdateRBSDto.cs
@@ -3,7 +3,7 @@
namespace API.DTOs;
#nullable enable
-public class UpdateRbsDto
+public sealed record UpdateRbsDto
{
public required string Username { get; init; }
public IList? Roles { get; init; }
diff --git a/API/DTOs/UpdateRatingDto.cs b/API/DTOs/UpdateRatingDto.cs
index f462fdc2b..472a94fe9 100644
--- a/API/DTOs/UpdateRatingDto.cs
+++ b/API/DTOs/UpdateRatingDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs;
-public class UpdateRatingDto
+public sealed record UpdateRatingDto
{
public int SeriesId { get; init; }
public int? ChapterId { get; init; }
diff --git a/API/DTOs/UpdateSeriesDto.cs b/API/DTOs/UpdateSeriesDto.cs
index ab4ffcb22..a4a9baf8c 100644
--- a/API/DTOs/UpdateSeriesDto.cs
+++ b/API/DTOs/UpdateSeriesDto.cs
@@ -1,7 +1,7 @@
namespace API.DTOs;
#nullable enable
-public class UpdateSeriesDto
+public sealed record UpdateSeriesDto
{
public int Id { get; init; }
public string? LocalizedName { get; init; }
diff --git a/API/DTOs/UpdateSeriesMetadataDto.cs b/API/DTOs/UpdateSeriesMetadataDto.cs
index 75150b3fa..5225f5486 100644
--- a/API/DTOs/UpdateSeriesMetadataDto.cs
+++ b/API/DTOs/UpdateSeriesMetadataDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs;
-public class UpdateSeriesMetadataDto
+public sealed record UpdateSeriesMetadataDto
{
public SeriesMetadataDto SeriesMetadata { get; set; } = null!;
}
diff --git a/API/DTOs/Uploads/UploadFileDto.cs b/API/DTOs/Uploads/UploadFileDto.cs
index 72fe7da9b..8d5cdf4cb 100644
--- a/API/DTOs/Uploads/UploadFileDto.cs
+++ b/API/DTOs/Uploads/UploadFileDto.cs
@@ -1,6 +1,6 @@
namespace API.DTOs.Uploads;
-public class UploadFileDto
+public sealed record UploadFileDto
{
///
/// Id of the Entity
diff --git a/API/DTOs/Uploads/UploadUrlDto.cs b/API/DTOs/Uploads/UploadUrlDto.cs
index f2699befd..3f4e625c3 100644
--- a/API/DTOs/Uploads/UploadUrlDto.cs
+++ b/API/DTOs/Uploads/UploadUrlDto.cs
@@ -2,7 +2,7 @@
namespace API.DTOs.Uploads;
-public class UploadUrlDto
+public sealed record UploadUrlDto
{
///
/// External url
diff --git a/API/DTOs/UserDto.cs b/API/DTOs/UserDto.cs
index e89e17df9..88dc97a5d 100644
--- a/API/DTOs/UserDto.cs
+++ b/API/DTOs/UserDto.cs
@@ -5,7 +5,7 @@ using API.DTOs.Account;
namespace API.DTOs;
#nullable enable
-public class UserDto
+public sealed record UserDto
{
public string Username { get; init; } = null!;
public string Email { get; init; } = null!;
diff --git a/API/DTOs/UserPreferencesDto.cs b/API/DTOs/UserPreferencesDto.cs
index 14987ae77..46f42306e 100644
--- a/API/DTOs/UserPreferencesDto.cs
+++ b/API/DTOs/UserPreferencesDto.cs
@@ -7,106 +7,8 @@ using API.Entities.Enums.UserPreferences;
namespace API.DTOs;
#nullable enable
-public class UserPreferencesDto
+public sealed record UserPreferencesDto
{
- ///
- /// Manga Reader Option: What direction should the next/prev page buttons go
- ///
- [Required]
- public ReadingDirection ReadingDirection { get; set; }
- ///
- /// Manga Reader Option: How should the image be scaled to screen
- ///
- [Required]
- public ScalingOption ScalingOption { get; set; }
- ///
- /// Manga Reader Option: Which side of a split image should we show first
- ///
- [Required]
- public PageSplitOption PageSplitOption { get; set; }
- ///
- /// Manga Reader Option: How the manga reader should perform paging or reading of the file
- ///
- /// Webtoon uses scrolling to page, LeftRight uses paging by clicking left/right side of reader, UpDown uses paging
- /// by clicking top/bottom sides of reader.
- ///
- ///
- [Required]
- public ReaderMode ReaderMode { get; set; }
- ///
- /// Manga Reader Option: How many pages to display in the reader at once
- ///
- [Required]
- public LayoutMode LayoutMode { get; set; }
- ///
- /// Manga Reader Option: Emulate a book by applying a shadow effect on the pages
- ///
- [Required]
- public bool EmulateBook { get; set; }
- ///
- /// Manga Reader Option: Background color of the reader
- ///
- [Required]
- public string BackgroundColor { get; set; } = "#000000";
- ///
- /// Manga Reader Option: Should swiping trigger pagination
- ///
- [Required]
- public bool SwipeToPaginate { get; set; }
- ///
- /// Manga Reader Option: Allow the menu to close after 6 seconds without interaction
- ///
- [Required]
- public bool AutoCloseMenu { get; set; }
- ///
- /// Manga Reader Option: Show screen hints to the user on some actions, ie) pagination direction change
- ///
- [Required]
- public bool ShowScreenHints { get; set; } = true;
- ///
- /// Manga Reader Option: Allow Automatic Webtoon detection
- ///
- [Required]
- public bool AllowAutomaticWebtoonReaderDetection { get; set; }
-
-
- ///
- /// Book Reader Option: Override extra Margin
- ///
- [Required]
- public int BookReaderMargin { get; set; }
- ///
- /// Book Reader Option: Override line-height
- ///
- [Required]
- public int BookReaderLineSpacing { get; set; }
- ///
- /// Book Reader Option: Override font size
- ///
- [Required]
- public int BookReaderFontSize { get; set; }
- ///
- /// Book Reader Option: Maps to the default Kavita font-family (inherit) or an override
- ///
- [Required]
- public string BookReaderFontFamily { get; set; } = null!;
-
- ///
- /// Book Reader Option: Allows tapping on side of screens to paginate
- ///
- [Required]
- public bool BookReaderTapToPaginate { get; set; }
- ///
- /// Book Reader Option: What direction should the next/prev page buttons go
- ///
- [Required]
- public ReadingDirection BookReaderReadingDirection { get; set; }
-
- ///
- /// Book Reader Option: What writing style should be used, horizontal or vertical.
- ///
- [Required]
- public WritingStyle BookReaderWritingStyle { get; set; }
///
/// UI Site Global Setting: The UI theme the user should use.
@@ -115,80 +17,28 @@ public class UserPreferencesDto
[Required]
public SiteThemeDto? Theme { get; set; }
- [Required] public string BookReaderThemeName { get; set; } = null!;
- [Required]
- public BookPageLayoutMode BookReaderLayoutMode { get; set; }
- ///
- /// Book Reader Option: A flag that hides the menu-ing system behind a click on the screen. This should be used with tap to paginate, but the app doesn't enforce this.
- ///
- /// Defaults to false
- [Required]
- public bool BookReaderImmersiveMode { get; set; } = false;
- ///
- /// Global Site Option: If the UI should layout items as Cards or List items
- ///
- /// Defaults to Cards
- [Required]
public PageLayoutMode GlobalPageLayoutMode { get; set; } = PageLayoutMode.Cards;
- ///
- /// UI Site Global Setting: If unread summaries should be blurred until expanded or unless user has read it already
- ///
- /// Defaults to false
+ ///
[Required]
public bool BlurUnreadSummaries { get; set; } = false;
- ///
- /// UI Site Global Setting: Should Kavita prompt user to confirm downloads that are greater than 100 MB.
- ///
+ ///
[Required]
public bool PromptForDownloadSize { get; set; } = true;
- ///
- /// UI Site Global Setting: Should Kavita disable CSS transitions
- ///
+ ///
[Required]
public bool NoTransitions { get; set; } = false;
- ///
- /// When showing series, only parent series or series with no relationships will be returned
- ///
+ ///
[Required]
public bool CollapseSeriesRelationships { get; set; } = false;
- ///
- /// UI Site Global Setting: Should series reviews be shared with all users in the server
- ///
+ ///
[Required]
public bool ShareReviews { get; set; } = false;
- ///
- /// UI Site Global Setting: The language locale that should be used for the user
- ///
+ ///
[Required]
public string Locale { get; set; }
- ///
- /// PDF Reader: Theme of the Reader
- ///
- [Required]
- public PdfTheme PdfTheme { get; set; } = PdfTheme.Dark;
- ///
- /// PDF Reader: Scroll mode of the reader
- ///
- [Required]
- public PdfScrollMode PdfScrollMode { get; set; } = PdfScrollMode.Vertical;
- ///
- /// PDF Reader: Layout Mode of the reader
- ///
- [Required]
- public PdfLayoutMode PdfLayoutMode { get; set; } = PdfLayoutMode.Multiple;
- ///
- /// PDF Reader: Spread Mode of the reader
- ///
- [Required]
- public PdfSpreadMode PdfSpreadMode { get; set; } = PdfSpreadMode.None;
-
- ///
- /// Kavita+: Should this account have Scrobbling enabled for AniList
- ///
+ ///
public bool AniListScrobblingEnabled { get; set; }
- ///
- /// Kavita+: Should this account have Want to Read Sync enabled
- ///
+ ///
public bool WantToReadSync { get; set; }
}
diff --git a/API/DTOs/UserReadingProfileDto.cs b/API/DTOs/UserReadingProfileDto.cs
new file mode 100644
index 000000000..24dbf1c34
--- /dev/null
+++ b/API/DTOs/UserReadingProfileDto.cs
@@ -0,0 +1,132 @@
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using API.Entities;
+using API.Entities.Enums;
+using API.Entities.Enums.UserPreferences;
+
+namespace API.DTOs;
+
+public sealed record UserReadingProfileDto
+{
+
+ public int Id { get; set; }
+ public int UserId { get; init; }
+
+ public string Name { get; init; }
+ public ReadingProfileKind Kind { get; init; }
+
+ #region MangaReader
+
+ ///
+ [Required]
+ public ReadingDirection ReadingDirection { get; set; }
+
+ ///
+ [Required]
+ public ScalingOption ScalingOption { get; set; }
+
+ ///
+ [Required]
+ public PageSplitOption PageSplitOption { get; set; }
+
+ ///
+ [Required]
+ public ReaderMode ReaderMode { get; set; }
+
+ ///
+ [Required]
+ public bool AutoCloseMenu { get; set; }
+
+ ///
+ [Required]
+ public bool ShowScreenHints { get; set; } = true;
+
+ ///
+ [Required]
+ public bool EmulateBook { get; set; }
+
+ ///
+ [Required]
+ public LayoutMode LayoutMode { get; set; }
+
+ ///
+ [Required]
+ public string BackgroundColor { get; set; } = "#000000";
+
+ ///
+ [Required]
+ public bool SwipeToPaginate { get; set; }
+
+ ///
+ [Required]
+ public bool AllowAutomaticWebtoonReaderDetection { get; set; }
+
+ ///
+ public int? WidthOverride { get; set; }
+
+ ///
+ public BreakPoint DisableWidthOverride { get; set; } = BreakPoint.Never;
+
+ #endregion
+
+ #region EpubReader
+
+ ///
+ [Required]
+ public int BookReaderMargin { get; set; }
+
+ ///
+ [Required]
+ public int BookReaderLineSpacing { get; set; }
+
+ ///
+ [Required]
+ public int BookReaderFontSize { get; set; }
+
+ ///
+ [Required]
+ public string BookReaderFontFamily { get; set; } = null!;
+
+ ///
+ [Required]
+ public bool BookReaderTapToPaginate { get; set; }
+
+ ///
+ [Required]
+ public ReadingDirection BookReaderReadingDirection { get; set; }
+
+ ///
+ [Required]
+ public WritingStyle BookReaderWritingStyle { get; set; }
+
+ ///
+ [Required]
+ public string BookReaderThemeName { get; set; } = null!;
+
+ ///
+ [Required]
+ public BookPageLayoutMode BookReaderLayoutMode { get; set; }
+
+ ///
+ [Required]
+ public bool BookReaderImmersiveMode { get; set; } = false;
+
+ #endregion
+
+ #region PdfReader
+
+ ///
+ [Required]
+ public PdfTheme PdfTheme { get; set; } = PdfTheme.Dark;
+
+ ///
+ [Required]
+ public PdfScrollMode PdfScrollMode { get; set; } = PdfScrollMode.Vertical;
+
+ ///
+ [Required]
+ public PdfSpreadMode PdfSpreadMode { get; set; } = PdfSpreadMode.None;
+
+ #endregion
+
+}
diff --git a/API/DTOs/VolumeDto.cs b/API/DTOs/VolumeDto.cs
index 8ef22a93b..fffccea59 100644
--- a/API/DTOs/VolumeDto.cs
+++ b/API/DTOs/VolumeDto.cs
@@ -1,5 +1,4 @@
-
-using System;
+using System;
using System.Collections.Generic;
using API.Entities;
using API.Entities.Interfaces;
@@ -8,14 +7,15 @@ using API.Services.Tasks.Scanner.Parser;
namespace API.DTOs;
-public class VolumeDto : IHasReadTimeEstimate, IHasCoverImage
+public sealed record VolumeDto : IHasReadTimeEstimate, IHasCoverImage
{
+ ///
public int Id { get; set; }
- ///
+ ///
public float MinNumber { get; set; }
- ///
+ ///
public float MaxNumber { get; set; }
- ///
+ ///
public string Name { get; set; } = default!;
///
/// This will map to MinNumber. Number was removed in v0.7.13.8/v0.7.14
@@ -24,17 +24,21 @@ public class VolumeDto : IHasReadTimeEstimate, IHasCoverImage
public int Number { get; set; }
public int Pages { get; set; }
public int PagesRead { get; set; }
+ ///
public DateTime LastModifiedUtc { get; set; }
+ ///
public DateTime CreatedUtc { get; set; }
///
/// When chapter was created in local server time
///
/// This is required for Tachiyomi Extension
+ ///
public DateTime Created { get; set; }
///
/// When chapter was last modified in local server time
///
/// This is required for Tachiyomi Extension
+ ///
public DateTime LastModified { get; set; }
public int SeriesId { get; set; }
public ICollection Chapters { get; set; } = new List();
@@ -64,10 +68,14 @@ public class VolumeDto : IHasReadTimeEstimate, IHasCoverImage
return MinNumber.Is(Parser.SpecialVolumeNumber);
}
+ ///
public string CoverImage { get; set; }
+ ///
private bool CoverImageLocked { get; set; }
- public string PrimaryColor { get; set; } = string.Empty;
- public string SecondaryColor { get; set; } = string.Empty;
+ ///
+ public string? PrimaryColor { get; set; } = string.Empty;
+ ///
+ public string? SecondaryColor { get; set; } = string.Empty;
public void ResetColorScape()
{
diff --git a/API/DTOs/WantToRead/UpdateWantToReadDto.cs b/API/DTOs/WantToRead/UpdateWantToReadDto.cs
index f1b38cea2..a5be26857 100644
--- a/API/DTOs/WantToRead/UpdateWantToReadDto.cs
+++ b/API/DTOs/WantToRead/UpdateWantToReadDto.cs
@@ -6,7 +6,7 @@ namespace API.DTOs.WantToRead;
///
/// A list of Series to pass when working with Want To Read APIs
///
-public class UpdateWantToReadDto
+public sealed record UpdateWantToReadDto
{
///
/// List of Series Ids that will be Added/Removed
diff --git a/API/Data/DataContext.cs b/API/Data/DataContext.cs
index 714e29fdf..7d529b1da 100644
--- a/API/Data/DataContext.cs
+++ b/API/Data/DataContext.cs
@@ -4,7 +4,6 @@ using System.Linq;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
-using API.DTOs.KavitaPlus.Metadata;
using API.Entities;
using API.Entities.Enums;
using API.Entities.Enums.UserPreferences;
@@ -18,7 +17,6 @@ using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
-using Microsoft.EntityFrameworkCore.Diagnostics;
namespace API.Data;
@@ -43,12 +41,13 @@ public sealed class DataContext : IdentityDbContext ServerSetting { get; set; } = null!;
public DbSet AppUserPreferences { get; set; } = null!;
public DbSet SeriesMetadata { get; set; } = null!;
- [Obsolete]
+ [Obsolete("Use AppUserCollection")]
public DbSet CollectionTag { get; set; } = null!;
public DbSet AppUserBookmark { get; set; } = null!;
public DbSet ReadingList { get; set; } = null!;
public DbSet ReadingListItem { get; set; } = null!;
public DbSet Person { get; set; } = null!;
+ public DbSet PersonAlias { get; set; } = null!;
public DbSet Genre { get; set; } = null!;
public DbSet Tag { get; set; } = null!;
public DbSet SiteTheme { get; set; } = null!;
@@ -71,7 +70,7 @@ public sealed class DataContext : IdentityDbContext ExternalSeriesMetadata { get; set; } = null!;
public DbSet ExternalRecommendation { get; set; } = null!;
public DbSet ManualMigrationHistory { get; set; } = null!;
- [Obsolete]
+ [Obsolete("Use IsBlacklisted field on Series")]
public DbSet SeriesBlacklist { get; set; } = null!;
public DbSet AppUserCollection { get; set; } = null!;
public DbSet ChapterPeople { get; set; } = null!;
@@ -80,6 +79,7 @@ public sealed class DataContext : IdentityDbContext MetadataSettings { get; set; } = null!;
public DbSet MetadataFieldMapping { get; set; } = null!;
public DbSet AppUserChapterRating { get; set; } = null!;
+ public DbSet AppUserReadingProfiles { get; set; } = null!;
protected override void OnModelCreating(ModelBuilder builder)
{
@@ -145,6 +145,9 @@ public sealed class DataContext : IdentityDbContext()
.Property(b => b.AllowMetadataMatching)
.HasDefaultValue(true);
+ builder.Entity()
+ .Property(b => b.EnableMetadata)
+ .HasDefaultValue(true);
builder.Entity()
.Property(b => b.WebLinks)
@@ -255,6 +258,48 @@ public sealed class DataContext : IdentityDbContext()
.Property(b => b.EnableCoverImage)
.HasDefaultValue(true);
+
+ builder.Entity()
+ .Property(b => b.BookThemeName)
+ .HasDefaultValue("Dark");
+ builder.Entity()
+ .Property(b => b.BackgroundColor)
+ .HasDefaultValue("#000000");
+ builder.Entity()
+ .Property(b => b.BookReaderWritingStyle)
+ .HasDefaultValue(WritingStyle.Horizontal);
+ builder.Entity()
+ .Property(b => b.AllowAutomaticWebtoonReaderDetection)
+ .HasDefaultValue(true);
+
+ builder.Entity()
+ .Property(rp => rp.LibraryIds)
+ .HasConversion(
+ v => JsonSerializer.Serialize(v, JsonSerializerOptions.Default),
+ v => JsonSerializer.Deserialize>(v, JsonSerializerOptions.Default) ?? new List())
+ .HasColumnType("TEXT");
+ builder.Entity()
+ .Property(rp => rp.SeriesIds)
+ .HasConversion(
+ v => JsonSerializer.Serialize(v, JsonSerializerOptions.Default),
+ v => JsonSerializer.Deserialize>(v, JsonSerializerOptions.Default) ?? new List())
+ .HasColumnType("TEXT");
+
+ builder.Entity()
+ .Property(sm => sm.KPlusOverrides)
+ .HasConversion(
+ v => JsonSerializer.Serialize(v, JsonSerializerOptions.Default),
+ v => JsonSerializer.Deserialize>(v, JsonSerializerOptions.Default) ??
+ new List())
+ .HasColumnType("TEXT")
+ .HasDefaultValue(new List());
+ builder.Entity()
+ .Property(sm => sm.KPlusOverrides)
+ .HasConversion(
+ v => JsonSerializer.Serialize(v, JsonSerializerOptions.Default),
+ v => JsonSerializer.Deserialize>(v, JsonSerializerOptions.Default) ?? new List())
+ .HasColumnType("TEXT")
+ .HasDefaultValue(new List());
}
#nullable enable
diff --git a/API/Data/ManualMigrations/v0.8.7/ManualMigrateReadingProfiles.cs b/API/Data/ManualMigrations/v0.8.7/ManualMigrateReadingProfiles.cs
new file mode 100644
index 000000000..b2afde98a
--- /dev/null
+++ b/API/Data/ManualMigrations/v0.8.7/ManualMigrateReadingProfiles.cs
@@ -0,0 +1,84 @@
+using System;
+using System.Threading.Tasks;
+using API.Entities;
+using API.Entities.Enums;
+using API.Entities.History;
+using API.Extensions;
+using API.Helpers.Builders;
+using Kavita.Common.EnvironmentInfo;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Logging;
+
+namespace API.Data.ManualMigrations;
+
+public static class ManualMigrateReadingProfiles
+{
+ public static async Task Migrate(DataContext context, ILogger logger)
+ {
+ if (await context.ManualMigrationHistory.AnyAsync(m => m.Name == "ManualMigrateReadingProfiles"))
+ {
+ return;
+ }
+
+ logger.LogCritical("Running ManualMigrateReadingProfiles migration - Please be patient, this may take some time. This is not an error");
+
+ var users = await context.AppUser
+ .Include(u => u.UserPreferences)
+ .Include(u => u.ReadingProfiles)
+ .ToListAsync();
+
+ foreach (var user in users)
+ {
+ var readingProfile = new AppUserReadingProfile
+ {
+ Name = "Default",
+ NormalizedName = "Default".ToNormalized(),
+ Kind = ReadingProfileKind.Default,
+ LibraryIds = [],
+ SeriesIds = [],
+ BackgroundColor = user.UserPreferences.BackgroundColor,
+ EmulateBook = user.UserPreferences.EmulateBook,
+ AppUser = user,
+ PdfTheme = user.UserPreferences.PdfTheme,
+ ReaderMode = user.UserPreferences.ReaderMode,
+ ReadingDirection = user.UserPreferences.ReadingDirection,
+ ScalingOption = user.UserPreferences.ScalingOption,
+ LayoutMode = user.UserPreferences.LayoutMode,
+ WidthOverride = null,
+ AppUserId = user.Id,
+ AutoCloseMenu = user.UserPreferences.AutoCloseMenu,
+ BookReaderMargin = user.UserPreferences.BookReaderMargin,
+ PageSplitOption = user.UserPreferences.PageSplitOption,
+ BookThemeName = user.UserPreferences.BookThemeName,
+ PdfSpreadMode = user.UserPreferences.PdfSpreadMode,
+ PdfScrollMode = user.UserPreferences.PdfScrollMode,
+ SwipeToPaginate = user.UserPreferences.SwipeToPaginate,
+ BookReaderFontFamily = user.UserPreferences.BookReaderFontFamily,
+ BookReaderFontSize = user.UserPreferences.BookReaderFontSize,
+ BookReaderImmersiveMode = user.UserPreferences.BookReaderImmersiveMode,
+ BookReaderLayoutMode = user.UserPreferences.BookReaderLayoutMode,
+ BookReaderLineSpacing = user.UserPreferences.BookReaderLineSpacing,
+ BookReaderReadingDirection = user.UserPreferences.BookReaderReadingDirection,
+ BookReaderWritingStyle = user.UserPreferences.BookReaderWritingStyle,
+ AllowAutomaticWebtoonReaderDetection = user.UserPreferences.AllowAutomaticWebtoonReaderDetection,
+ BookReaderTapToPaginate = user.UserPreferences.BookReaderTapToPaginate,
+ ShowScreenHints = user.UserPreferences.ShowScreenHints,
+ };
+ user.ReadingProfiles.Add(readingProfile);
+ }
+
+ await context.SaveChangesAsync();
+
+ context.ManualMigrationHistory.Add(new ManualMigrationHistory
+ {
+ Name = "ManualMigrateReadingProfiles",
+ ProductVersion = BuildInfo.Version.ToString(),
+ RanAt = DateTime.UtcNow,
+ });
+ await context.SaveChangesAsync();
+
+
+ logger.LogCritical("Running ManualMigrateReadingProfiles migration - Completed. This is not an error");
+
+ }
+}
diff --git a/API/Data/Migrations/20250507221026_PersonAliases.Designer.cs b/API/Data/Migrations/20250507221026_PersonAliases.Designer.cs
new file mode 100644
index 000000000..5d76571e1
--- /dev/null
+++ b/API/Data/Migrations/20250507221026_PersonAliases.Designer.cs
@@ -0,0 +1,3571 @@
+//
+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("20250507221026_PersonAliases")]
+ partial class PersonAliases
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "9.0.4");
+
+ modelBuilder.Entity("API.Entities.AppRole", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property("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("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AccessFailedCount")
+ .HasColumnType("INTEGER");
+
+ b.Property("AgeRestriction")
+ .HasColumnType("INTEGER");
+
+ b.Property("AgeRestrictionIncludeUnknowns")
+ .HasColumnType("INTEGER");
+
+ b.Property("AniListAccessToken")
+ .HasColumnType("TEXT");
+
+ b.Property("ApiKey")
+ .HasColumnType("TEXT");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("TEXT");
+
+ b.Property("ConfirmationToken")
+ .HasColumnType("TEXT");
+
+ b.Property("Created")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("Email")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property("EmailConfirmed")
+ .HasColumnType("INTEGER");
+
+ b.Property("HasRunScrobbleEventGeneration")
+ .HasColumnType("INTEGER");
+
+ b.Property("LastActive")
+ .HasColumnType("TEXT");
+
+ b.Property("LastActiveUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("LockoutEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property("LockoutEnd")
+ .HasColumnType("TEXT");
+
+ b.Property("MalAccessToken")
+ .HasColumnType("TEXT");
+
+ b.Property