mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-06-13 18:44:14 -04:00
* Fixed a scaling issue in the epub reader, where images could scale when they shouldn't. * Removed some caching on library/ api and added more output for a foreign key constraint * Hooked in Restricted Profile stat collection * Added a new boolean on age restrictions to explicitly allow unknowns or not. Since unknown is the default state of metadata, if users are allowed access to Unknown, age restricted content could leak. * Fixed a bug where sometimes series cover generation could fail under conditions where only specials existed. * Fixed foreign constraint issue when cleaning up series not seen at end of scan loop * Removed an additional epub parse when scanning and handled merging differently * Code smell
49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using System.Linq;
|
|
using API.Data.Misc;
|
|
using API.Entities;
|
|
using API.Entities.Enums;
|
|
|
|
namespace API.Extensions;
|
|
|
|
public static class QueryableExtensions
|
|
{
|
|
public static IQueryable<Series> RestrictAgainstAgeRestriction(this IQueryable<Series> queryable, AgeRestriction restriction)
|
|
{
|
|
if (restriction.AgeRating == AgeRating.NotApplicable) return queryable;
|
|
var q = queryable.Where(s => s.Metadata.AgeRating <= restriction.AgeRating);
|
|
if (!restriction.IncludeUnknowns)
|
|
{
|
|
return q.Where(s => s.Metadata.AgeRating != AgeRating.Unknown);
|
|
}
|
|
|
|
return q;
|
|
}
|
|
|
|
public static IQueryable<CollectionTag> RestrictAgainstAgeRestriction(this IQueryable<CollectionTag> queryable, AgeRestriction restriction)
|
|
{
|
|
if (restriction.AgeRating == AgeRating.NotApplicable) return queryable;
|
|
|
|
if (restriction.IncludeUnknowns)
|
|
{
|
|
return queryable.Where(c => c.SeriesMetadatas.All(sm =>
|
|
sm.AgeRating <= restriction.AgeRating));
|
|
}
|
|
|
|
return queryable.Where(c => c.SeriesMetadatas.All(sm =>
|
|
sm.AgeRating <= restriction.AgeRating && sm.AgeRating > AgeRating.Unknown));
|
|
}
|
|
|
|
public static IQueryable<ReadingList> RestrictAgainstAgeRestriction(this IQueryable<ReadingList> queryable, AgeRestriction restriction)
|
|
{
|
|
if (restriction.AgeRating == AgeRating.NotApplicable) return queryable;
|
|
var q = queryable.Where(rl => rl.AgeRating <= restriction.AgeRating);
|
|
|
|
if (!restriction.IncludeUnknowns)
|
|
{
|
|
return q.Where(rl => rl.AgeRating != AgeRating.Unknown);
|
|
}
|
|
|
|
return q;
|
|
}
|
|
}
|