Merge pull request #9139 from Jpuc1143/tag-whitelist

This commit is contained in:
Bond-009 2023-02-11 23:52:09 +01:00 committed by GitHub
commit f5417c50f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 40 additions and 1 deletions

View File

@ -232,3 +232,4 @@
- [Matthew Jones](https://github.com/matthew-jones-uk) - [Matthew Jones](https://github.com/matthew-jones-uk)
- [Jakob Kukla](https://github.com/jakobkukla) - [Jakob Kukla](https://github.com/jakobkukla)
- [Utku Özdemir](https://github.com/utkuozdemir) - [Utku Özdemir](https://github.com/utkuozdemir)
- [JPUC1143](https://github.com/Jpuc1143/)

View File

@ -4477,6 +4477,24 @@ namespace Emby.Server.Implementations.Data
} }
} }
if (query.IncludeInheritedTags.Length > 0)
{
var paramName = "@IncludeInheritedTags";
if (statement is null)
{
int index = 0;
string includedTags = string.Join(',', query.IncludeInheritedTags.Select(_ => paramName + index++));
whereClauses.Add("((select CleanValue from ItemValues where ItemId=Guid and Type=6 and cleanvalue in (" + includedTags + ")) is not null)");
}
else
{
for (int index = 0; index < query.IncludeInheritedTags.Length; index++)
{
statement.TryBind(paramName + index, GetCleanValue(query.IncludeInheritedTags[index]));
}
}
}
if (query.SeriesStatuses.Length > 0) if (query.SeriesStatuses.Length > 0)
{ {
var statuses = new List<string>(); var statuses = new List<string>();

View File

@ -63,6 +63,11 @@ namespace Jellyfin.Data.Enums
/// <summary> /// <summary>
/// A list of ordered views. /// A list of ordered views.
/// </summary> /// </summary>
OrderedViews = 11 OrderedViews = 11,
/// <summary>
/// A list of allowed tags.
/// </summary>
AllowedTags = 12
} }
} }

View File

@ -371,6 +371,7 @@ namespace Jellyfin.Server.Implementations.Users
EnablePublicSharing = user.HasPermission(PermissionKind.EnablePublicSharing), EnablePublicSharing = user.HasPermission(PermissionKind.EnablePublicSharing),
AccessSchedules = user.AccessSchedules.ToArray(), AccessSchedules = user.AccessSchedules.ToArray(),
BlockedTags = user.GetPreference(PreferenceKind.BlockedTags), BlockedTags = user.GetPreference(PreferenceKind.BlockedTags),
AllowedTags = user.GetPreference(PreferenceKind.AllowedTags),
EnabledChannels = user.GetPreferenceValues<Guid>(PreferenceKind.EnabledChannels), EnabledChannels = user.GetPreferenceValues<Guid>(PreferenceKind.EnabledChannels),
EnabledDevices = user.GetPreference(PreferenceKind.EnabledDevices), EnabledDevices = user.GetPreference(PreferenceKind.EnabledDevices),
EnabledFolders = user.GetPreferenceValues<Guid>(PreferenceKind.EnabledFolders), EnabledFolders = user.GetPreferenceValues<Guid>(PreferenceKind.EnabledFolders),
@ -696,6 +697,7 @@ namespace Jellyfin.Server.Implementations.Users
// TODO: fix this at some point // TODO: fix this at some point
user.SetPreference(PreferenceKind.BlockUnratedItems, policy.BlockUnratedItems ?? Array.Empty<UnratedItem>()); user.SetPreference(PreferenceKind.BlockUnratedItems, policy.BlockUnratedItems ?? Array.Empty<UnratedItem>());
user.SetPreference(PreferenceKind.BlockedTags, policy.BlockedTags); user.SetPreference(PreferenceKind.BlockedTags, policy.BlockedTags);
user.SetPreference(PreferenceKind.AllowedTags, policy.AllowedTags);
user.SetPreference(PreferenceKind.EnabledChannels, policy.EnabledChannels); user.SetPreference(PreferenceKind.EnabledChannels, policy.EnabledChannels);
user.SetPreference(PreferenceKind.EnabledDevices, policy.EnabledDevices); user.SetPreference(PreferenceKind.EnabledDevices, policy.EnabledDevices);
user.SetPreference(PreferenceKind.EnabledFolders, policy.EnabledFolders); user.SetPreference(PreferenceKind.EnabledFolders, policy.EnabledFolders);

View File

@ -1607,6 +1607,12 @@ namespace MediaBrowser.Controller.Entities
return false; return false;
} }
var allowedTagsPreference = user.GetPreference(PreferenceKind.AllowedTags);
if (allowedTagsPreference.Any() && !allowedTagsPreference.Any(i => Tags.Contains(i, StringComparison.OrdinalIgnoreCase)))
{
return false;
}
return true; return true;
} }

View File

@ -26,6 +26,7 @@ namespace MediaBrowser.Controller.Entities
EnableTotalRecordCount = true; EnableTotalRecordCount = true;
ExcludeArtistIds = Array.Empty<Guid>(); ExcludeArtistIds = Array.Empty<Guid>();
ExcludeInheritedTags = Array.Empty<string>(); ExcludeInheritedTags = Array.Empty<string>();
IncludeInheritedTags = Array.Empty<string>();
ExcludeItemIds = Array.Empty<Guid>(); ExcludeItemIds = Array.Empty<Guid>();
ExcludeItemTypes = Array.Empty<BaseItemKind>(); ExcludeItemTypes = Array.Empty<BaseItemKind>();
ExcludeTags = Array.Empty<string>(); ExcludeTags = Array.Empty<string>();
@ -95,6 +96,8 @@ namespace MediaBrowser.Controller.Entities
public string[] ExcludeInheritedTags { get; set; } public string[] ExcludeInheritedTags { get; set; }
public string[] IncludeInheritedTags { get; set; }
public IReadOnlyList<string> Genres { get; set; } public IReadOnlyList<string> Genres { get; set; }
public bool? IsSpecialSeason { get; set; } public bool? IsSpecialSeason { get; set; }
@ -368,6 +371,7 @@ namespace MediaBrowser.Controller.Entities
} }
ExcludeInheritedTags = user.GetPreference(PreferenceKind.BlockedTags); ExcludeInheritedTags = user.GetPreference(PreferenceKind.BlockedTags);
IncludeInheritedTags = user.GetPreference(PreferenceKind.AllowedTags);
User = user; User = user;
} }

View File

@ -35,6 +35,7 @@ namespace MediaBrowser.Model.Users
EnableSharedDeviceControl = true; EnableSharedDeviceControl = true;
BlockedTags = Array.Empty<string>(); BlockedTags = Array.Empty<string>();
AllowedTags = Array.Empty<string>();
BlockUnratedItems = Array.Empty<UnratedItem>(); BlockUnratedItems = Array.Empty<UnratedItem>();
EnableUserPreferenceAccess = true; EnableUserPreferenceAccess = true;
@ -86,6 +87,8 @@ namespace MediaBrowser.Model.Users
public string[] BlockedTags { get; set; } public string[] BlockedTags { get; set; }
public string[] AllowedTags { get; set; }
public bool EnableUserPreferenceAccess { get; set; } public bool EnableUserPreferenceAccess { get; set; }
public AccessSchedule[] AccessSchedules { get; set; } public AccessSchedule[] AccessSchedules { get; set; }