Restrict people, genres, studios and artists to names backed by an item the user can access

This commit is contained in:
Shadowghost
2026-07-28 20:41:21 +02:00
parent 5f5c71ab75
commit 9a258c089d
11 changed files with 2003 additions and 8 deletions
+17
View File
@@ -162,6 +162,23 @@ public static class UserEntityExtensions
return Array.IndexOf(GetPreferenceValues<Guid>(entity, PreferenceKind.GroupedFolders), id) != -1;
}
/// <summary>
/// Checks whether any library, parental rating or tag rule keeps content from this user.
/// </summary>
/// <param name="entity">The user to check.</param>
/// <returns><c>True</c> if some content in the library is hidden from this user.</returns>
public static bool HasContentRestrictions(this User entity)
{
ArgumentNullException.ThrowIfNull(entity);
return !entity.HasPermission(PermissionKind.EnableAllFolders)
|| entity.GetPreference(PreferenceKind.BlockedMediaFolders).Length > 0
|| entity.MaxParentalRatingScore.HasValue
|| entity.GetPreference(PreferenceKind.BlockedTags).Length > 0
|| entity.GetPreference(PreferenceKind.AllowedTags).Length > 0
|| entity.GetPreference(PreferenceKind.BlockUnratedItems).Length > 0;
}
/// <summary>
/// Initializes the default permissions for a user. Should only be called on user creation.
/// </summary>