diff options
| author | Shadowghost <Ghost_of_Stone@web.de> | 2026-07-28 20:41:21 +0200 |
|---|---|---|
| committer | Shadowghost <Ghost_of_Stone@web.de> | 2026-07-28 21:28:56 +0200 |
| commit | 9a258c089dcbc68b12fe63479542fc7158ec7a10 (patch) | |
| tree | 16218c953371e84636f51de505cce659deb3c169 /Jellyfin.Data/UserEntityExtensions.cs | |
| parent | 5f5c71ab7542d4dab088773b4ec4f75a369b83cc (diff) | |
Restrict people, genres, studios and artists to names backed by an item the user can access
Diffstat (limited to 'Jellyfin.Data/UserEntityExtensions.cs')
| -rw-r--r-- | Jellyfin.Data/UserEntityExtensions.cs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Jellyfin.Data/UserEntityExtensions.cs b/Jellyfin.Data/UserEntityExtensions.cs index 0fc8d3cd25..c6468daa2e 100644 --- a/Jellyfin.Data/UserEntityExtensions.cs +++ b/Jellyfin.Data/UserEntityExtensions.cs @@ -163,6 +163,23 @@ public static class UserEntityExtensions } /// <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> /// <param name="entity">The entity to update.</param> |
