mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Fix playlist parental control and no parental control skipping forbidden unrated items
This commit is contained in:
parent
9d21f078c7
commit
07dc163844
@ -83,13 +83,14 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public IReadOnlyList<BaseItemDto> GetBaseItemDtos(IReadOnlyList<BaseItem> items, DtoOptions options, User user = null, BaseItem owner = null)
|
public IReadOnlyList<BaseItemDto> GetBaseItemDtos(IReadOnlyList<BaseItem> items, DtoOptions options, User user = null, BaseItem owner = null)
|
||||||
{
|
{
|
||||||
var returnItems = new BaseItemDto[items.Count];
|
var accessibleItems = user is null ? items : items.Where(x => x.IsVisible(user)).ToList();
|
||||||
|
var returnItems = new BaseItemDto[accessibleItems.Count];
|
||||||
var programTuples = new List<(BaseItem, BaseItemDto)>();
|
var programTuples = new List<(BaseItem, BaseItemDto)>();
|
||||||
var channelTuples = new List<(BaseItemDto, LiveTvChannel)>();
|
var channelTuples = new List<(BaseItemDto, LiveTvChannel)>();
|
||||||
|
|
||||||
for (int index = 0; index < items.Count; index++)
|
for (int index = 0; index < accessibleItems.Count; index++)
|
||||||
{
|
{
|
||||||
var item = items[index];
|
var item = accessibleItems[index];
|
||||||
var dto = GetBaseItemDtoInternal(item, options, user, owner);
|
var dto = GetBaseItemDtoInternal(item, options, user, owner);
|
||||||
|
|
||||||
if (item is LiveTvChannel tvChannel)
|
if (item is LiveTvChannel tvChannel)
|
||||||
|
@ -1534,12 +1534,6 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
var maxAllowedRating = user.MaxParentalAgeRating;
|
var maxAllowedRating = user.MaxParentalAgeRating;
|
||||||
|
|
||||||
if (maxAllowedRating is null)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var rating = CustomRatingForComparison;
|
var rating = CustomRatingForComparison;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(rating))
|
if (string.IsNullOrEmpty(rating))
|
||||||
@ -1549,12 +1543,13 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
|
|
||||||
if (string.IsNullOrEmpty(rating))
|
if (string.IsNullOrEmpty(rating))
|
||||||
{
|
{
|
||||||
|
Logger.LogDebug("{0} has no parental rating set.", Name);
|
||||||
return !GetBlockUnratedValue(user);
|
return !GetBlockUnratedValue(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
var value = LocalizationManager.GetRatingLevel(rating);
|
var value = LocalizationManager.GetRatingLevel(rating);
|
||||||
|
|
||||||
// Could not determine the integer value
|
// Could not determine rating level
|
||||||
if (!value.HasValue)
|
if (!value.HasValue)
|
||||||
{
|
{
|
||||||
var isAllowed = !GetBlockUnratedValue(user);
|
var isAllowed = !GetBlockUnratedValue(user);
|
||||||
@ -1567,7 +1562,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
return isAllowed;
|
return isAllowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
return value.Value <= maxAllowedRating.Value;
|
return !maxAllowedRating.HasValue || value.Value <= maxAllowedRating.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int? GetInheritedParentalRatingValue()
|
public int? GetInheritedParentalRatingValue()
|
||||||
@ -1627,10 +1622,10 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the block unrated value.
|
/// Gets a bool indicating if access to the unrated item is blocked or not.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="user">The configuration.</param>
|
/// <param name="user">The configuration.</param>
|
||||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if blocked, <c>false</c> otherwise.</returns>
|
||||||
protected virtual bool GetBlockUnratedValue(User user)
|
protected virtual bool GetBlockUnratedValue(User user)
|
||||||
{
|
{
|
||||||
// Don't block plain folders that are unrated. Let the media underneath get blocked
|
// Don't block plain folders that are unrated. Let the media underneath get blocked
|
||||||
|
Loading…
x
Reference in New Issue
Block a user