From a94588497c521a89aa4a78eba44e305d06d91aa8 Mon Sep 17 00:00:00 2001 From: Shadowghost Date: Tue, 28 Jul 2026 23:13:10 +0200 Subject: Fix Folder access filtering --- .../Item/BaseItemRepository.QueryBuilding.cs | 42 ++++++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'Jellyfin.Server.Implementations/Item/BaseItemRepository.QueryBuilding.cs') diff --git a/Jellyfin.Server.Implementations/Item/BaseItemRepository.QueryBuilding.cs b/Jellyfin.Server.Implementations/Item/BaseItemRepository.QueryBuilding.cs index a4de9feb05..9d16f7976a 100644 --- a/Jellyfin.Server.Implementations/Item/BaseItemRepository.QueryBuilding.cs +++ b/Jellyfin.Server.Implementations/Item/BaseItemRepository.QueryBuilding.cs @@ -395,6 +395,17 @@ public sealed partial class BaseItemRepository return ApplyAccessFiltering(context, baseQuery, filter); } + /// + /// Checks whether the user restricts access to items by parental rating or tags. + /// + /// The query filter. + /// true if the query carries parental restrictions. + private static bool RequiresParentalRestrictions(InternalItemsQuery filter) + => filter.IncludeInheritedTags.Length > 0 + || filter.ExcludeInheritedTags.Length > 0 + || filter.MaxParentalRating is not null + || filter.BlockUnratedItems.Length > 0; + /// /// Applies user access filtering to a query. /// Includes TopParentIds, parental rating, and tag filtering. @@ -412,6 +423,30 @@ public sealed partial class BaseItemRepository baseQuery = baseQuery.Where(e => topParentIds.Contains(e.TopParentId!.Value)); } + baseQuery = ApplyParentalRestrictions(context, baseQuery, filter); + + // Exclude alternate versions (have PrimaryVersionId set) and owned non-extra items. + // Extras (trailers, etc.) have OwnerId set but also have ExtraType set — keep those. + if (!filter.IncludeOwnedItems) + { + baseQuery = baseQuery.Where(e => e.PrimaryVersionId == null && (e.OwnerId == null || e.ExtraType != null)); + } + + return baseQuery; + } + + /// + /// Applies the user's parental rating and tag restrictions to a query. + /// + /// The database context. + /// The query to filter. + /// The query filter. + /// The filtered query. + private IQueryable ApplyParentalRestrictions( + JellyfinDbContext context, + IQueryable baseQuery, + InternalItemsQuery filter) + { // Apply parental rating filtering if (filter.MaxParentalRating is not null) { @@ -462,13 +497,6 @@ public sealed partial class BaseItemRepository || e.Type == personTypeName); } - // Exclude alternate versions (have PrimaryVersionId set) and owned non-extra items. - // Extras (trailers, etc.) have OwnerId set but also have ExtraType set — keep those. - if (!filter.IncludeOwnedItems) - { - baseQuery = baseQuery.Where(e => e.PrimaryVersionId == null && (e.OwnerId == null || e.ExtraType != null)); - } - return baseQuery; } -- cgit v1.2.3