mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 18:08:53 -07:00
added an allow mode filter for tags
This commit is contained in:
parent
ac68e0ba41
commit
01828f19a7
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Channels
|
namespace MediaBrowser.Controller.Channels
|
||||||
{
|
{
|
||||||
@ -72,5 +73,10 @@ namespace MediaBrowser.Controller.Channels
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool IsTagFilterEnforced(TagFilterMode mode)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1080,7 +1080,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
|
|
||||||
if (hasTags != null)
|
if (hasTags != null)
|
||||||
{
|
{
|
||||||
if (user.Policy.BlockedTags.Any(i => hasTags.Tags.Contains(i, StringComparer.OrdinalIgnoreCase)))
|
if (user.Policy.TagFilters.Any(i => !IsTagFilterAccepted(hasTags, i)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1089,6 +1089,36 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsTagFilterAccepted(IHasTags hasTags, TagFilter filter)
|
||||||
|
{
|
||||||
|
if (IsTagFilterEnforced(filter.Mode))
|
||||||
|
{
|
||||||
|
if (filter.Mode == TagFilterMode.Block)
|
||||||
|
{
|
||||||
|
// If content has the tag, it's not allowed
|
||||||
|
if (hasTags.Tags.Contains(filter.Tag, StringComparer.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (filter.Mode == TagFilterMode.Allow)
|
||||||
|
{
|
||||||
|
// If content doesn't have the tag, it's not allowed
|
||||||
|
if (!hasTags.Tags.Contains(filter.Tag, StringComparer.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual bool IsTagFilterEnforced(TagFilterMode mode)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the block unrated value.
|
/// Gets the block unrated value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -14,6 +14,7 @@ using System.Linq;
|
|||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities
|
namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
@ -79,6 +80,19 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool IsTagFilterEnforced(TagFilterMode mode)
|
||||||
|
{
|
||||||
|
if (this is ICollectionFolder)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this is UserView)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether this instance is physical root.
|
/// Gets or sets a value indicating whether this instance is physical root.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -15,11 +15,11 @@ namespace MediaBrowser.Dlna.Profiles
|
|||||||
Name = "Xbox 360";
|
Name = "Xbox 360";
|
||||||
|
|
||||||
// Required according to above
|
// Required according to above
|
||||||
ModelName = "Windows Media Connect";
|
ModelName = "Windows Media Player Sharing";
|
||||||
|
|
||||||
ModelNumber = "12.0";
|
ModelNumber = "12.0";
|
||||||
|
|
||||||
FriendlyName = "${HostName} : 1 : Windows Media Connect";
|
FriendlyName = "${HostName} : 1";
|
||||||
|
|
||||||
ModelUrl = "http://www.microsoft.com/";
|
ModelUrl = "http://www.microsoft.com/";
|
||||||
Manufacturer = "Microsoft Corporation";
|
Manufacturer = "Microsoft Corporation";
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
<HttpHeaderInfo name="User-Agent" value="Xenon" match="Substring" />
|
<HttpHeaderInfo name="User-Agent" value="Xenon" match="Substring" />
|
||||||
</Headers>
|
</Headers>
|
||||||
</Identification>
|
</Identification>
|
||||||
<FriendlyName>${HostName} : 1 : Windows Media Connect</FriendlyName>
|
<FriendlyName>${HostName} : 1</FriendlyName>
|
||||||
<Manufacturer>Microsoft Corporation</Manufacturer>
|
<Manufacturer>Microsoft Corporation</Manufacturer>
|
||||||
<ManufacturerUrl>http://www.microsoft.com/</ManufacturerUrl>
|
<ManufacturerUrl>http://www.microsoft.com/</ManufacturerUrl>
|
||||||
<ModelName>Windows Media Connect</ModelName>
|
<ModelName>Windows Media Player Sharing</ModelName>
|
||||||
<ModelDescription>Media Browser</ModelDescription>
|
<ModelDescription>Media Browser</ModelDescription>
|
||||||
<ModelNumber>12.0</ModelNumber>
|
<ModelNumber>12.0</ModelNumber>
|
||||||
<ModelUrl>http://www.microsoft.com/</ModelUrl>
|
<ModelUrl>http://www.microsoft.com/</ModelUrl>
|
||||||
|
@ -1181,6 +1181,12 @@
|
|||||||
<Compile Include="..\MediaBrowser.Model\Users\PinRedeemResult.cs">
|
<Compile Include="..\MediaBrowser.Model\Users\PinRedeemResult.cs">
|
||||||
<Link>Users\PinRedeemResult.cs</Link>
|
<Link>Users\PinRedeemResult.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\MediaBrowser.Model\Users\TagFilter.cs">
|
||||||
|
<Link>Users\TagFilter.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\MediaBrowser.Model\Users\TagFilterMode.cs">
|
||||||
|
<Link>Users\TagFilterMode.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\MediaBrowser.Model\Users\UserAction.cs">
|
<Compile Include="..\MediaBrowser.Model\Users\UserAction.cs">
|
||||||
<Link>Users\UserAction.cs</Link>
|
<Link>Users\UserAction.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -1140,6 +1140,12 @@
|
|||||||
<Compile Include="..\MediaBrowser.Model\Users\PinRedeemResult.cs">
|
<Compile Include="..\MediaBrowser.Model\Users\PinRedeemResult.cs">
|
||||||
<Link>Users\PinRedeemResult.cs</Link>
|
<Link>Users\PinRedeemResult.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\MediaBrowser.Model\Users\TagFilter.cs">
|
||||||
|
<Link>Users\TagFilter.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\MediaBrowser.Model\Users\TagFilterMode.cs">
|
||||||
|
<Link>Users\TagFilterMode.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\MediaBrowser.Model\Users\UserAction.cs">
|
<Compile Include="..\MediaBrowser.Model\Users\UserAction.cs">
|
||||||
<Link>Users\UserAction.cs</Link>
|
<Link>Users\UserAction.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -433,6 +433,8 @@
|
|||||||
<Compile Include="Users\ForgotPasswordAction.cs" />
|
<Compile Include="Users\ForgotPasswordAction.cs" />
|
||||||
<Compile Include="Users\ForgotPasswordResult.cs" />
|
<Compile Include="Users\ForgotPasswordResult.cs" />
|
||||||
<Compile Include="Users\PinRedeemResult.cs" />
|
<Compile Include="Users\PinRedeemResult.cs" />
|
||||||
|
<Compile Include="Users\TagFilter.cs" />
|
||||||
|
<Compile Include="Users\TagFilterMode.cs" />
|
||||||
<Compile Include="Users\UserAction.cs" />
|
<Compile Include="Users\UserAction.cs" />
|
||||||
<Compile Include="Users\UserActionType.cs" />
|
<Compile Include="Users\UserActionType.cs" />
|
||||||
<Compile Include="Users\UserPolicy.cs" />
|
<Compile Include="Users\UserPolicy.cs" />
|
||||||
|
9
MediaBrowser.Model/Users/TagFilter.cs
Normal file
9
MediaBrowser.Model/Users/TagFilter.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
namespace MediaBrowser.Model.Users
|
||||||
|
{
|
||||||
|
public class TagFilter
|
||||||
|
{
|
||||||
|
public string Tag { get; set; }
|
||||||
|
public TagFilterMode Mode { get; set; }
|
||||||
|
}
|
||||||
|
}
|
9
MediaBrowser.Model/Users/TagFilterMode.cs
Normal file
9
MediaBrowser.Model/Users/TagFilterMode.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
namespace MediaBrowser.Model.Users
|
||||||
|
{
|
||||||
|
public enum TagFilterMode
|
||||||
|
{
|
||||||
|
Block = 0,
|
||||||
|
Allow = 1
|
||||||
|
}
|
||||||
|
}
|
@ -58,6 +58,8 @@ namespace MediaBrowser.Model.Users
|
|||||||
|
|
||||||
public string[] EnabledFolders { get; set; }
|
public string[] EnabledFolders { get; set; }
|
||||||
public bool EnableAllFolders { get; set; }
|
public bool EnableAllFolders { get; set; }
|
||||||
|
|
||||||
|
public TagFilter[] TagFilters { get; set; }
|
||||||
|
|
||||||
public UserPolicy()
|
public UserPolicy()
|
||||||
{
|
{
|
||||||
@ -66,7 +68,6 @@ namespace MediaBrowser.Model.Users
|
|||||||
EnableLiveTvAccess = true;
|
EnableLiveTvAccess = true;
|
||||||
EnableSharedDeviceControl = true;
|
EnableSharedDeviceControl = true;
|
||||||
|
|
||||||
BlockedTags = new string[] { };
|
|
||||||
BlockUnratedItems = new UnratedItem[] { };
|
BlockUnratedItems = new UnratedItem[] { };
|
||||||
|
|
||||||
EnableUserPreferenceAccess = true;
|
EnableUserPreferenceAccess = true;
|
||||||
@ -83,6 +84,8 @@ namespace MediaBrowser.Model.Users
|
|||||||
EnableAllDevices = true;
|
EnableAllDevices = true;
|
||||||
|
|
||||||
EnableContentDownloading = true;
|
EnableContentDownloading = true;
|
||||||
|
|
||||||
|
TagFilters = new TagFilter[] { };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,6 +168,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||||||
foreach (var user in users)
|
foreach (var user in users)
|
||||||
{
|
{
|
||||||
await DoPolicyMigration(user).ConfigureAwait(false);
|
await DoPolicyMigration(user).ConfigureAwait(false);
|
||||||
|
await DoBlockedTagMigration(user).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are no local users with admin rights, make them all admins
|
// If there are no local users with admin rights, make them all admins
|
||||||
@ -346,6 +347,25 @@ namespace MediaBrowser.Server.Implementations.Library
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task DoBlockedTagMigration(User user)
|
||||||
|
{
|
||||||
|
if (user.Policy.BlockedTags != null)
|
||||||
|
{
|
||||||
|
user.Policy.TagFilters = user.Policy
|
||||||
|
.BlockedTags
|
||||||
|
.Select(i => new TagFilter
|
||||||
|
{
|
||||||
|
Tag = i,
|
||||||
|
Mode = TagFilterMode.Block
|
||||||
|
})
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
user.Policy.BlockedTags = null;
|
||||||
|
|
||||||
|
await UpdateUserPolicy(user, user.Policy, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public UserDto GetUserDto(User user, string remoteEndPoint = null)
|
public UserDto GetUserDto(User user, string remoteEndPoint = null)
|
||||||
{
|
{
|
||||||
if (user == null)
|
if (user == null)
|
||||||
|
@ -276,7 +276,7 @@
|
|||||||
"ButtonStart": "Start",
|
"ButtonStart": "Start",
|
||||||
"HeaderChannels": "Channels",
|
"HeaderChannels": "Channels",
|
||||||
"HeaderMediaFolders": "Media Folders",
|
"HeaderMediaFolders": "Media Folders",
|
||||||
"HeaderBlockItemsWithNoRating": "Block items with no rating information:",
|
"HeaderBlockItemsWithNoRating": "Block content with no rating information:",
|
||||||
"OptionBlockOthers": "Others",
|
"OptionBlockOthers": "Others",
|
||||||
"OptionBlockTvShows": "TV Shows",
|
"OptionBlockTvShows": "TV Shows",
|
||||||
"OptionBlockTrailers": "Trailers",
|
"OptionBlockTrailers": "Trailers",
|
||||||
|
@ -1356,8 +1356,10 @@
|
|||||||
"HeaderVideoTypes": "Video Types",
|
"HeaderVideoTypes": "Video Types",
|
||||||
"HeaderYears": "Years",
|
"HeaderYears": "Years",
|
||||||
"HeaderAddTag": "Add Tag",
|
"HeaderAddTag": "Add Tag",
|
||||||
"LabelBlockItemsWithTags": "Block items with tags:",
|
"LabelBlockOrAllowItemsWithTags": "Block or allow content with tags:",
|
||||||
"LabelTag": "Tag:",
|
"LabelTag": "Tag:",
|
||||||
|
"OptionBlockItemWithTag": "Block all content with this tag",
|
||||||
|
"OptionAllowItemWithTag": "Allow only content with this tag",
|
||||||
"LabelEnableSingleImageInDidlLimit": "Limit to single embedded image",
|
"LabelEnableSingleImageInDidlLimit": "Limit to single embedded image",
|
||||||
"LabelEnableSingleImageInDidlLimitHelp": "Some devices will not render properly if multiple images are embedded within Didl.",
|
"LabelEnableSingleImageInDidlLimitHelp": "Some devices will not render properly if multiple images are embedded within Didl.",
|
||||||
"TabActivity": "Activity",
|
"TabActivity": "Activity",
|
||||||
@ -1368,5 +1370,7 @@
|
|||||||
"NameSeasonNumber": "Season {0}",
|
"NameSeasonNumber": "Season {0}",
|
||||||
"LabelNewUserNameHelp": "Usernames can contain letters (a-z), numbers (0-9), dashes (-), underscores (_), apostrophes ('), and periods (.)",
|
"LabelNewUserNameHelp": "Usernames can contain letters (a-z), numbers (0-9), dashes (-), underscores (_), apostrophes ('), and periods (.)",
|
||||||
"TabJobs": "Jobs",
|
"TabJobs": "Jobs",
|
||||||
"TabSyncJobs": "Sync Jobs"
|
"TabSyncJobs": "Sync Jobs",
|
||||||
|
"LabelTagFilterMode": "Mode:",
|
||||||
|
"LabelTagFilterAllowModeHelp": "If used as part of a deeply nested folder structure, content that is tagged with this mechanism will require parent folders to be tagged as well."
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@
|
|||||||
<Content Include="dashboard-ui\css\images\server.png">
|
<Content Include="dashboard-ui\css\images\server.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="dashboard-ui\css\images\splash.png">
|
<Content Include="dashboard-ui\css\images\splash.jpg">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="dashboard-ui\css\images\tour\dashboard\help.png">
|
<Content Include="dashboard-ui\css\images\tour\dashboard\help.png">
|
||||||
|
Loading…
Reference in New Issue
Block a user