mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-04 06:48:35 +01:00
start using user policy
This commit is contained in:
@@ -8,6 +8,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using MediaBrowser.Model.Users;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities.Audio
|
||||
{
|
||||
@@ -173,7 +174,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
return base.GetUserDataKey();
|
||||
}
|
||||
|
||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
||||
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||
{
|
||||
return config.BlockUnratedItems.Contains(UnratedItem.Music);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using MediaBrowser.Model.Users;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities.Audio
|
||||
{
|
||||
@@ -154,7 +155,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
return base.GetUserDataKey();
|
||||
}
|
||||
|
||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
||||
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||
{
|
||||
return config.BlockUnratedItems.Contains(UnratedItem.Music);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Users;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities.Audio
|
||||
{
|
||||
@@ -114,7 +115,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
return "Artist-" + item.Name;
|
||||
}
|
||||
|
||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
||||
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||
{
|
||||
return config.BlockUnratedItems.Contains(UnratedItem.Music);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Users;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
@@ -595,7 +596,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// <returns>PlayAccess.</returns>
|
||||
public PlayAccess GetPlayAccess(User user)
|
||||
{
|
||||
if (!user.Configuration.EnableMediaPlayback)
|
||||
if (!user.Policy.EnableMediaPlayback)
|
||||
{
|
||||
return PlayAccess.None;
|
||||
}
|
||||
@@ -987,7 +988,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
return false;
|
||||
}
|
||||
|
||||
var maxAllowedRating = user.Configuration.MaxParentalRating;
|
||||
var maxAllowedRating = user.Policy.MaxParentalRating;
|
||||
|
||||
if (maxAllowedRating == null)
|
||||
{
|
||||
@@ -1003,7 +1004,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
if (string.IsNullOrWhiteSpace(rating))
|
||||
{
|
||||
return !GetBlockUnratedValue(user.Configuration);
|
||||
return !GetBlockUnratedValue(user.Policy);
|
||||
}
|
||||
|
||||
var value = LocalizationManager.GetRatingLevel(rating);
|
||||
@@ -1023,7 +1024,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
if (hasTags != null)
|
||||
{
|
||||
if (user.Configuration.BlockedTags.Any(i => hasTags.Tags.Contains(i, StringComparer.OrdinalIgnoreCase)))
|
||||
if (user.Policy.BlockedTags.Any(i => hasTags.Tags.Contains(i, StringComparer.OrdinalIgnoreCase)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1037,7 +1038,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// </summary>
|
||||
/// <param name="config">The configuration.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
protected virtual bool GetBlockUnratedValue(UserConfiguration config)
|
||||
protected virtual bool GetBlockUnratedValue(UserPolicy config)
|
||||
{
|
||||
return config.BlockUnratedItems.Contains(UnratedItem.Other);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Model.Users;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
@@ -36,7 +37,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
Tags = new List<string>();
|
||||
}
|
||||
|
||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
||||
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||
{
|
||||
return config.BlockUnratedItems.Contains(UnratedItem.Book);
|
||||
}
|
||||
|
||||
@@ -303,10 +303,10 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
if (this is ICollectionFolder)
|
||||
{
|
||||
if (user.Configuration.BlockedMediaFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase) ||
|
||||
if (user.Policy.BlockedMediaFolders.Contains(Id.ToString("N"), StringComparer.OrdinalIgnoreCase) ||
|
||||
|
||||
// Backwards compatibility
|
||||
user.Configuration.BlockedMediaFolders.Contains(Name, StringComparer.OrdinalIgnoreCase))
|
||||
user.Policy.BlockedMediaFolders.Contains(Name, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Model.Users;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
@@ -108,7 +109,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
return base.GetDeletePaths();
|
||||
}
|
||||
|
||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
||||
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||
{
|
||||
return config.BlockUnratedItems.Contains(UnratedItem.Game);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using System;
|
||||
using MediaBrowser.Model.Users;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
@@ -43,7 +44,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
return base.GetUserDataKey();
|
||||
}
|
||||
|
||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
||||
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||
{
|
||||
// Don't block. Determine by game
|
||||
return false;
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Users;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities.Movies
|
||||
{
|
||||
@@ -67,7 +68,7 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||
/// <value>The display order.</value>
|
||||
public string DisplayOrder { get; set; }
|
||||
|
||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
||||
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||
{
|
||||
return config.BlockUnratedItems.Contains(UnratedItem.Movie);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Model.Users;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities.Movies
|
||||
{
|
||||
@@ -146,7 +147,7 @@ namespace MediaBrowser.Controller.Entities.Movies
|
||||
return itemsChanged;
|
||||
}
|
||||
|
||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
||||
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||
{
|
||||
return config.BlockUnratedItems.Contains(UnratedItem.Movie);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using MediaBrowser.Model.Users;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
@@ -80,7 +81,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
return this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? base.GetUserDataKey();
|
||||
}
|
||||
|
||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
||||
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||
{
|
||||
return config.BlockUnratedItems.Contains(UnratedItem.Music);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using MediaBrowser.Model.Drawing;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using MediaBrowser.Model.Users;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
@@ -69,8 +70,8 @@ namespace MediaBrowser.Controller.Entities
|
||||
public double? Longitude { get; set; }
|
||||
public double? Altitude { get; set; }
|
||||
public int? IsoSpeedRating { get; set; }
|
||||
|
||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
||||
|
||||
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||
{
|
||||
return config.BlockUnratedItems.Contains(UnratedItem.Other);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using MediaBrowser.Model.Users;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
@@ -22,8 +23,8 @@ namespace MediaBrowser.Controller.Entities
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
||||
|
||||
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||
{
|
||||
return config.BlockUnratedItems.Contains(UnratedItem.Other);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using MediaBrowser.Model.Users;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities.TV
|
||||
{
|
||||
@@ -274,7 +275,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
return new[] { Path };
|
||||
}
|
||||
|
||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
||||
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||
{
|
||||
return config.BlockUnratedItems.Contains(UnratedItem.Series);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using MediaBrowser.Model.Querying;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using MediaBrowser.Model.Users;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities.TV
|
||||
{
|
||||
@@ -249,7 +250,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
return GetEpisodes(user);
|
||||
}
|
||||
|
||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
||||
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||
{
|
||||
// Don't block. Let either the entire series rating or episode rating determine it
|
||||
return false;
|
||||
|
||||
@@ -7,6 +7,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using MediaBrowser.Model.Users;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities.TV
|
||||
{
|
||||
@@ -246,7 +247,7 @@ namespace MediaBrowser.Controller.Entities.TV
|
||||
});
|
||||
}
|
||||
|
||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
||||
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||
{
|
||||
return config.BlockUnratedItems.Contains(UnratedItem.Series);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using MediaBrowser.Model.Users;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
@@ -98,7 +99,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
return base.GetUserDataKey();
|
||||
}
|
||||
|
||||
protected override bool GetBlockUnratedValue(UserConfiguration config)
|
||||
protected override bool GetBlockUnratedValue(UserPolicy config)
|
||||
{
|
||||
return config.BlockUnratedItems.Contains(UnratedItem.Trailer);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Connect;
|
||||
@@ -107,37 +106,27 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// <value>The last activity date.</value>
|
||||
public DateTime? LastActivityDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The _configuration
|
||||
/// </summary>
|
||||
private UserConfiguration _configuration;
|
||||
/// <summary>
|
||||
/// The _configuration initialized
|
||||
/// </summary>
|
||||
private bool _configurationInitialized;
|
||||
/// <summary>
|
||||
/// The _configuration sync lock
|
||||
/// </summary>
|
||||
private object _configurationSyncLock = new object();
|
||||
/// <summary>
|
||||
/// Gets the user's configuration
|
||||
/// </summary>
|
||||
/// <value>The configuration.</value>
|
||||
private UserConfiguration _config;
|
||||
private readonly object _configSyncLock = new object();
|
||||
[IgnoreDataMember]
|
||||
public UserConfiguration Configuration
|
||||
{
|
||||
get
|
||||
{
|
||||
// Lazy load
|
||||
LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationInitialized, ref _configurationSyncLock, () => (UserConfiguration)ConfigurationHelper.GetXmlConfiguration(typeof(UserConfiguration), ConfigurationFilePath, XmlSerializer));
|
||||
return _configuration;
|
||||
}
|
||||
private set
|
||||
{
|
||||
_configuration = value;
|
||||
if (_config == null)
|
||||
{
|
||||
lock (_configSyncLock)
|
||||
{
|
||||
if (_config == null)
|
||||
{
|
||||
_config = UserManager.GetUserConfiguration(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_configurationInitialized = value != null;
|
||||
return _config;
|
||||
}
|
||||
set { _config = value; }
|
||||
}
|
||||
|
||||
private UserPolicy _policy;
|
||||
@@ -256,35 +245,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
return System.IO.Path.Combine(parentPath, Id.ToString("N"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the user's configuration file
|
||||
/// </summary>
|
||||
/// <value>The configuration file path.</value>
|
||||
[IgnoreDataMember]
|
||||
public string ConfigurationFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return System.IO.Path.Combine(ConfigurationDirectoryPath, "config.xml");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the configuration.
|
||||
/// </summary>
|
||||
/// <param name="config">The config.</param>
|
||||
/// <exception cref="System.ArgumentNullException">config</exception>
|
||||
public void UpdateConfiguration(UserConfiguration config)
|
||||
{
|
||||
if (config == null)
|
||||
{
|
||||
throw new ArgumentNullException("config");
|
||||
}
|
||||
|
||||
Configuration = config;
|
||||
UserManager.UpdateConfiguration(this, Configuration);
|
||||
}
|
||||
|
||||
public bool IsParentalScheduleAllowed()
|
||||
{
|
||||
return IsParentalScheduleAllowed(DateTime.UtcNow);
|
||||
@@ -292,7 +252,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
public bool IsParentalScheduleAllowed(DateTime date)
|
||||
{
|
||||
var schedules = Configuration.AccessSchedules;
|
||||
var schedules = Policy.AccessSchedules;
|
||||
|
||||
if (schedules.Length == 0)
|
||||
{
|
||||
|
||||
@@ -63,7 +63,8 @@ namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
CollectionType.Books,
|
||||
CollectionType.HomeVideos,
|
||||
CollectionType.Photos
|
||||
CollectionType.Photos,
|
||||
string.Empty
|
||||
};
|
||||
|
||||
var collectionFolder = folder as ICollectionFolder;
|
||||
|
||||
Reference in New Issue
Block a user