diff --git a/MediaBrowser.Controller/Channels/Channel.cs b/MediaBrowser.Controller/Channels/Channel.cs index ab76f4e67..b6514ca0a 100644 --- a/MediaBrowser.Controller/Channels/Channel.cs +++ b/MediaBrowser.Controller/Channels/Channel.cs @@ -74,7 +74,7 @@ namespace MediaBrowser.Controller.Channels return false; } - protected override bool IsTagFilterEnforced(TagFilterMode mode) + protected override bool IsAllowTagFilterEnforced() { return false; } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 75a09a7b0..89706f917 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1080,31 +1080,14 @@ namespace MediaBrowser.Controller.Entities if (hasTags != null) { - if (user.Policy.TagFilters.Any(i => !IsTagFilterAccepted(hasTags, i))) + var policy = user.Policy; + if (policy.BlockedTags.Any(i => hasTags.Tags.Contains(i, StringComparer.OrdinalIgnoreCase))) { return false; } - } - - return true; - } - - private bool IsTagFilterAccepted(IHasTags hasTags, TagFilter filter) - { - if (IsTagFilterEnforced(filter.Mode)) - { - if (filter.Mode == TagFilterMode.Block) + if (policy.AllowedTags.Length > 0 && IsAllowTagFilterEnforced()) { - // 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)) + if (policy.AllowedTags.Any(i => !hasTags.Tags.Contains(i, StringComparer.OrdinalIgnoreCase))) { return false; } @@ -1114,7 +1097,7 @@ namespace MediaBrowser.Controller.Entities return true; } - protected virtual bool IsTagFilterEnforced(TagFilterMode mode) + protected virtual bool IsAllowTagFilterEnforced() { return true; } diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index fe9bea53b..0d9bb03ac 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -80,7 +80,7 @@ namespace MediaBrowser.Controller.Entities } } - protected override bool IsTagFilterEnforced(TagFilterMode mode) + protected override bool IsAllowTagFilterEnforced() { if (this is ICollectionFolder) { diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index 561ae1e41..ba3065bc9 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -1181,12 +1181,6 @@ Users\PinRedeemResult.cs - - Users\TagFilter.cs - - - Users\TagFilterMode.cs - Users\UserAction.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index bf5624f7a..8d22f25a9 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -1140,12 +1140,6 @@ Users\PinRedeemResult.cs - - Users\TagFilter.cs - - - Users\TagFilterMode.cs - Users\UserAction.cs diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 7f71c85c5..c8e09dd82 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -433,8 +433,6 @@ - - diff --git a/MediaBrowser.Model/Users/TagFilter.cs b/MediaBrowser.Model/Users/TagFilter.cs deleted file mode 100644 index 5a30c435c..000000000 --- a/MediaBrowser.Model/Users/TagFilter.cs +++ /dev/null @@ -1,9 +0,0 @@ - -namespace MediaBrowser.Model.Users -{ - public class TagFilter - { - public string Tag { get; set; } - public TagFilterMode Mode { get; set; } - } -} diff --git a/MediaBrowser.Model/Users/TagFilterMode.cs b/MediaBrowser.Model/Users/TagFilterMode.cs deleted file mode 100644 index bce75b41f..000000000 --- a/MediaBrowser.Model/Users/TagFilterMode.cs +++ /dev/null @@ -1,9 +0,0 @@ - -namespace MediaBrowser.Model.Users -{ - public enum TagFilterMode - { - Block = 0, - Allow = 1 - } -} diff --git a/MediaBrowser.Model/Users/UserPolicy.cs b/MediaBrowser.Model/Users/UserPolicy.cs index c82b887ba..3e27340d8 100644 --- a/MediaBrowser.Model/Users/UserPolicy.cs +++ b/MediaBrowser.Model/Users/UserPolicy.cs @@ -29,6 +29,7 @@ namespace MediaBrowser.Model.Users public int? MaxParentalRating { get; set; } public string[] BlockedTags { get; set; } + public string[] AllowedTags { get; set; } public bool EnableUserPreferenceAccess { get; set; } public AccessSchedule[] AccessSchedules { get; set; } public UnratedItem[] BlockUnratedItems { get; set; } @@ -59,8 +60,6 @@ namespace MediaBrowser.Model.Users public string[] EnabledFolders { get; set; } public bool EnableAllFolders { get; set; } - public TagFilter[] TagFilters { get; set; } - public UserPolicy() { EnableLiveTvManagement = true; @@ -68,6 +67,8 @@ namespace MediaBrowser.Model.Users EnableLiveTvAccess = true; EnableSharedDeviceControl = true; + BlockedTags = new string[] { }; + AllowedTags = new string[] { }; BlockUnratedItems = new UnratedItem[] { }; EnableUserPreferenceAccess = true; @@ -84,8 +85,6 @@ namespace MediaBrowser.Model.Users EnableAllDevices = true; EnableContentDownloading = true; - - TagFilters = new TagFilter[] { }; } } -} +} \ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/Library/UserManager.cs b/MediaBrowser.Server.Implementations/Library/UserManager.cs index 47903525b..b8bc8585e 100644 --- a/MediaBrowser.Server.Implementations/Library/UserManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserManager.cs @@ -168,7 +168,6 @@ namespace MediaBrowser.Server.Implementations.Library foreach (var user in users) { await DoPolicyMigration(user).ConfigureAwait(false); - await DoBlockedTagMigration(user).ConfigureAwait(false); } // If there are no local users with admin rights, make them all admins @@ -347,25 +346,6 @@ 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) { if (user == null) @@ -1036,4 +1016,4 @@ namespace MediaBrowser.Server.Implementations.Library } } } -} +} \ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index b31db164a..9d2c98c83 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -727,7 +727,5 @@ "SyncJobItemStatusSynced": "Synced", "SyncJobItemStatusFailed": "Failed", "SyncJobItemStatusRemovedFromDevice": "Removed from device", - "SyncJobItemStatusCancelled": "Cancelled", - "MessageBlockContentWithThisTag": "Block all content with this tag", - "MessageAllowContentWithThisTag": "Allow only content with this tag" + "SyncJobItemStatusCancelled": "Cancelled" } diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index e78b19c05..c28a61da4 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -1356,10 +1356,9 @@ "HeaderVideoTypes": "Video Types", "HeaderYears": "Years", "HeaderAddTag": "Add Tag", - "LabelBlockOrAllowItemsWithTags": "Block or allow content with tags:", + "LabelBlockContentWithTags": "Block content with tags:", + "LabelAllowContentWithTags": "Allow only content with tags:", "LabelTag": "Tag:", - "OptionBlockItemWithTag": "Block all content with this tag", - "OptionAllowItemWithTag": "Allow only content with this tag", "LabelEnableSingleImageInDidlLimit": "Limit to single embedded image", "LabelEnableSingleImageInDidlLimitHelp": "Some devices will not render properly if multiple images are embedded within Didl.", "TabActivity": "Activity", @@ -1372,5 +1371,5 @@ "TabJobs": "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." + "LabelTagFilterAllowModeHelp": "If allowed tags are used as part of a deeply nested folder structure, content that is tagged will require parent folders to be tagged as well." }