sync updates

This commit is contained in:
Luke Pulverenti
2015-01-20 00:19:13 -05:00
parent 4ea72584db
commit 1d5f1bc474
22 changed files with 146 additions and 74 deletions

View File

@@ -572,7 +572,7 @@ namespace MediaBrowser.Server.Implementations.Connect
Id = response.Id,
ImageUrl = response.UserImageUrl,
UserName = response.UserName,
ExcludedLibraries = request.ExcludedLibraries,
EnabledLibraries = request.EnabledLibraries,
EnabledChannels = request.EnabledChannels,
EnableLiveTv = request.EnableLiveTv,
AccessToken = accessToken
@@ -833,10 +833,13 @@ namespace MediaBrowser.Server.Implementations.Connect
if (currentPendingEntry != null)
{
user.Policy.EnableLiveTvAccess = currentPendingEntry.EnableLiveTv;
user.Policy.BlockedMediaFolders = currentPendingEntry.ExcludedLibraries;
user.Policy.EnabledFolders = currentPendingEntry.EnabledLibraries;
user.Policy.EnableAllFolders = false;
user.Policy.EnabledChannels = currentPendingEntry.EnabledChannels;
user.Policy.EnableAllChannels = false;
user.Policy.EnableLiveTvAccess = currentPendingEntry.EnableLiveTv;
}
await _userManager.UpdateConfiguration(user.Id.ToString("N"), user.Configuration);
@@ -964,7 +967,7 @@ namespace MediaBrowser.Server.Implementations.Connect
ConnectUserId = i.ConnectUserId,
EnableLiveTv = i.EnableLiveTv,
EnabledChannels = i.EnabledChannels,
ExcludedLibraries = i.ExcludedLibraries,
EnabledLibraries = i.EnabledLibraries,
Id = i.Id,
ImageUrl = i.ImageUrl,
UserName = i.UserName

View File

@@ -100,11 +100,16 @@ namespace MediaBrowser.Server.Implementations.Devices
devices = devices.Where(i => GetCapabilities(i.Id).SupportsSync == val);
}
if (query.SupportsUniqueIdentifier.HasValue)
if (query.SupportsPersistentIdentifier.HasValue)
{
var val = query.SupportsUniqueIdentifier.Value;
var val = query.SupportsPersistentIdentifier.Value;
devices = devices.Where(i => GetCapabilities(i.Id).SupportsUniqueIdentifier == val);
devices = devices.Where(i =>
{
var caps = GetCapabilities(i.Id);
var deviceVal = caps.SupportsUniqueIdentifier ?? caps.SupportsPersistentIdentifier;
return deviceVal == val;
});
}
if (!string.IsNullOrWhiteSpace(query.UserId))
@@ -212,7 +217,7 @@ namespace MediaBrowser.Server.Implementations.Devices
{
var capabilities = GetCapabilities(deviceId);
if (capabilities.SupportsUniqueIdentifier)
if (capabilities != null && capabilities.SupportsPersistentIdentifier)
{
return false;
}

View File

@@ -73,10 +73,11 @@ namespace MediaBrowser.Server.Implementations.Library
private readonly Func<IDtoService> _dtoServiceFactory;
private readonly Func<IConnectManager> _connectFactory;
private readonly Func<IChannelManager> _channelManager;
private readonly Func<ILibraryManager> _libraryManager;
private readonly IServerApplicationHost _appHost;
private readonly IFileSystem _fileSystem;
public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func<IImageProcessor> imageProcessorFactory, Func<IDtoService> dtoServiceFactory, Func<IConnectManager> connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, Func<IChannelManager> channelManager)
public UserManager(ILogger logger, IServerConfigurationManager configurationManager, IUserRepository userRepository, IXmlSerializer xmlSerializer, INetworkManager networkManager, Func<IImageProcessor> imageProcessorFactory, Func<IDtoService> dtoServiceFactory, Func<IConnectManager> connectFactory, IServerApplicationHost appHost, IJsonSerializer jsonSerializer, IFileSystem fileSystem, Func<IChannelManager> channelManager, Func<ILibraryManager> libraryManager)
{
_logger = logger;
UserRepository = userRepository;
@@ -89,6 +90,7 @@ namespace MediaBrowser.Server.Implementations.Library
_jsonSerializer = jsonSerializer;
_fileSystem = fileSystem;
_channelManager = channelManager;
_libraryManager = libraryManager;
ConfigurationManager = configurationManager;
Users = new List<User>();
@@ -173,6 +175,7 @@ namespace MediaBrowser.Server.Implementations.Library
{
await DoPolicyMigration(user).ConfigureAwait(false);
await DoChannelMigration(user).ConfigureAwait(false);
await DoLibraryMigration(user).ConfigureAwait(false);
}
// If there are no local users with admin rights, make them all admins
@@ -389,6 +392,39 @@ namespace MediaBrowser.Server.Implementations.Library
}
}
private async Task DoLibraryMigration(User user)
{
if (user.Policy.BlockedMediaFolders != null)
{
if (user.Policy.BlockedMediaFolders.Length > 0)
{
user.Policy.EnableAllFolders = false;
try
{
user.Policy.EnabledFolders = _libraryManager().RootFolder
.Children
.Where(i => !user.Policy.BlockedMediaFolders.Contains(i.Name, StringComparer.OrdinalIgnoreCase) && !user.Policy.BlockedMediaFolders.Contains(i.Id.ToString("N"), StringComparer.OrdinalIgnoreCase))
.Select(i => i.Id.ToString("N"))
.ToArray();
}
catch
{
user.Policy.EnabledFolders = new string[] { };
}
}
else
{
user.Policy.EnableAllFolders = true;
user.Policy.EnabledFolders = new string[] { };
}
user.Policy.BlockedMediaFolders = null;
await UpdateUserPolicy(user, user.Policy, false);
}
}
public UserDto GetUserDto(User user, string remoteEndPoint = null)
{
if (user == null)

View File

@@ -6,6 +6,8 @@
"Administrator": "Administrator",
"Password": "Password",
"DeleteImage": "Delete Image",
"MessageThankYouForSupporting": "Thank you for supporting Media Browser.",
"MessagePleaseSupportMediaBrowser": "Please support Media Browser.",
"DeleteImageConfirmation": "Are you sure you wish to delete this image?",
"FileReadCancelled": "The file read has been canceled.",
"FileNotFound": "File not found.",
@@ -219,6 +221,7 @@
"ButtonResume": "Resume",
"HeaderScenes": "Scenes",
"HeaderAudioTracks": "Audio Tracks",
"HeaderLibraries": "Libraries",
"LabelUnknownLanguage": "Unknown language",
"HeaderSubtitles": "Subtitles",
"HeaderVideoQuality": "Video Quality",

View File

@@ -79,6 +79,7 @@
"ReferToMediaLibraryWiki": "Refer to the media library wiki.",
"LabelCountry": "Country:",
"LabelLanguage": "Language:",
"ButtonJoinTheDevelopmentTeam": "Join the Development Team",
"HeaderPreferredMetadataLanguage": "Preferred metadata language:",
"LabelSaveLocalMetadata": "Save artwork and metadata into media folders",
"LabelSaveLocalMetadataHelp": "Saving artwork and metadata directly into media folders will put them in a place where they can be easily edited.",
@@ -97,6 +98,7 @@
"HeaderDeviceAccess": "Device Access",
"OptionEnableAccessFromAllDevices": "Enable access from all devices",
"OptionEnableAccessToAllChannels": "Enable access to all channels",
"OptionEnableAccessToAllLibraries": "Enable access to all libraries",
"DeviceAccessHelp": "This only applies to devices that can be uniquely identified and will not prevent browser access. Filtering user device access will prevent them from using new devices until they've been approved here.",
"LabelDisplayMissingEpisodesWithinSeasons": "Display missing episodes within seasons",
"LabelUnairedMissingEpisodesWithinSeasons": "Display unaired episodes within seasons",