revise opt-in tags

pull/702/head
Luke Pulverenti 9 years ago
parent d5c4655361
commit f03f2346f3

@ -74,7 +74,7 @@ namespace MediaBrowser.Controller.Channels
return false;
}
protected override bool IsTagFilterEnforced(TagFilterMode mode)
protected override bool IsAllowTagFilterEnforced()
{
return false;
}

@ -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 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 (policy.AllowedTags.Length > 0 && IsAllowTagFilterEnforced())
{
// 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;
}

@ -80,7 +80,7 @@ namespace MediaBrowser.Controller.Entities
}
}
protected override bool IsTagFilterEnforced(TagFilterMode mode)
protected override bool IsAllowTagFilterEnforced()
{
if (this is ICollectionFolder)
{

@ -1181,12 +1181,6 @@
<Compile Include="..\MediaBrowser.Model\Users\PinRedeemResult.cs">
<Link>Users\PinRedeemResult.cs</Link>
</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">
<Link>Users\UserAction.cs</Link>
</Compile>

@ -1140,12 +1140,6 @@
<Compile Include="..\MediaBrowser.Model\Users\PinRedeemResult.cs">
<Link>Users\PinRedeemResult.cs</Link>
</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">
<Link>Users\UserAction.cs</Link>
</Compile>

@ -433,8 +433,6 @@
<Compile Include="Users\ForgotPasswordAction.cs" />
<Compile Include="Users\ForgotPasswordResult.cs" />
<Compile Include="Users\PinRedeemResult.cs" />
<Compile Include="Users\TagFilter.cs" />
<Compile Include="Users\TagFilterMode.cs" />
<Compile Include="Users\UserAction.cs" />
<Compile Include="Users\UserActionType.cs" />
<Compile Include="Users\UserPolicy.cs" />

@ -1,9 +0,0 @@

namespace MediaBrowser.Model.Users
{
public class TagFilter
{
public string Tag { get; set; }
public TagFilterMode Mode { get; set; }
}
}

@ -1,9 +0,0 @@

namespace MediaBrowser.Model.Users
{
public enum TagFilterMode
{
Block = 0,
Allow = 1
}
}

@ -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[] { };
}
}
}
}

@ -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
}
}
}
}
}

@ -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"
}

@ -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."
}

Loading…
Cancel
Save