Fix playlist parental control and no parental control skipping forbidden unrated items

This commit is contained in:
Shadowghost
2022-11-30 11:55:40 +01:00
parent 9d21f078c7
commit 07dc163844
2 changed files with 9 additions and 13 deletions

View File

@@ -1534,12 +1534,6 @@ namespace MediaBrowser.Controller.Entities
}
var maxAllowedRating = user.MaxParentalAgeRating;
if (maxAllowedRating is null)
{
return true;
}
var rating = CustomRatingForComparison;
if (string.IsNullOrEmpty(rating))
@@ -1549,12 +1543,13 @@ namespace MediaBrowser.Controller.Entities
if (string.IsNullOrEmpty(rating))
{
Logger.LogDebug("{0} has no parental rating set.", Name);
return !GetBlockUnratedValue(user);
}
var value = LocalizationManager.GetRatingLevel(rating);
// Could not determine the integer value
// Could not determine rating level
if (!value.HasValue)
{
var isAllowed = !GetBlockUnratedValue(user);
@@ -1567,7 +1562,7 @@ namespace MediaBrowser.Controller.Entities
return isAllowed;
}
return value.Value <= maxAllowedRating.Value;
return !maxAllowedRating.HasValue || value.Value <= maxAllowedRating.Value;
}
public int? GetInheritedParentalRatingValue()
@@ -1627,10 +1622,10 @@ namespace MediaBrowser.Controller.Entities
}
/// <summary>
/// Gets the block unrated value.
/// Gets a bool indicating if access to the unrated item is blocked or not.
/// </summary>
/// <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)
{
// Don't block plain folders that are unrated. Let the media underneath get blocked