mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-02-06 12:42:24 +00:00
make channel access opt-in rather than opt out
This commit is contained in:
@@ -96,7 +96,7 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
|
||||
public static string GetUserDistinctValue(User user)
|
||||
{
|
||||
var channels = user.Policy.BlockedChannels
|
||||
var channels = user.Policy.EnabledChannels
|
||||
.OrderBy(i => i)
|
||||
.ToList();
|
||||
|
||||
@@ -374,7 +374,7 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(path);
|
||||
_fileSystem.DeleteFile(path);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
|
||||
@@ -1492,7 +1492,7 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
}
|
||||
else
|
||||
{
|
||||
File.Delete(response.TempFilePath);
|
||||
_fileSystem.DeleteFile(response.TempFilePath);
|
||||
|
||||
throw new ApplicationException("Unexpected response type encountered: " + response.ContentType);
|
||||
}
|
||||
@@ -1501,7 +1501,7 @@ namespace MediaBrowser.Server.Implementations.Channels
|
||||
|
||||
try
|
||||
{
|
||||
File.Delete(response.TempFilePath);
|
||||
_fileSystem.DeleteFile(response.TempFilePath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace MediaBrowser.Server.Implementations.Collections
|
||||
{
|
||||
foreach (var file in shortcutFilesToDelete)
|
||||
{
|
||||
File.Delete(file);
|
||||
_fileSystem.DeleteFile(file);
|
||||
}
|
||||
|
||||
foreach (var child in list)
|
||||
|
||||
@@ -548,7 +548,7 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||
ImageUrl = response.UserImageUrl,
|
||||
UserName = response.UserName,
|
||||
ExcludedLibraries = request.ExcludedLibraries,
|
||||
ExcludedChannels = request.ExcludedChannels,
|
||||
EnabledChannels = request.EnabledChannels,
|
||||
EnableLiveTv = request.EnableLiveTv,
|
||||
AccessToken = accessToken
|
||||
});
|
||||
@@ -810,7 +810,8 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||
{
|
||||
user.Policy.EnableLiveTvAccess = currentPendingEntry.EnableLiveTv;
|
||||
user.Policy.BlockedMediaFolders = currentPendingEntry.ExcludedLibraries;
|
||||
user.Policy.BlockedChannels = currentPendingEntry.ExcludedChannels;
|
||||
user.Policy.EnabledChannels = currentPendingEntry.EnabledChannels;
|
||||
user.Policy.EnableAllChannels = false;
|
||||
}
|
||||
|
||||
await _userManager.UpdateConfiguration(user.Id.ToString("N"), user.Configuration);
|
||||
@@ -937,7 +938,7 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||
{
|
||||
ConnectUserId = i.ConnectUserId,
|
||||
EnableLiveTv = i.EnableLiveTv,
|
||||
ExcludedChannels = i.ExcludedChannels,
|
||||
EnabledChannels = i.EnabledChannels,
|
||||
ExcludedLibraries = i.ExcludedLibraries,
|
||||
Id = i.Id,
|
||||
ImageUrl = i.ImageUrl,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Devices;
|
||||
using MediaBrowser.Model.Devices;
|
||||
using MediaBrowser.Model.Logging;
|
||||
@@ -21,14 +22,16 @@ namespace MediaBrowser.Server.Implementations.Devices
|
||||
private readonly IApplicationPaths _appPaths;
|
||||
private readonly IJsonSerializer _json;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
private ConcurrentBag<DeviceInfo> _devices;
|
||||
|
||||
public DeviceRepository(IApplicationPaths appPaths, IJsonSerializer json, ILogger logger)
|
||||
public DeviceRepository(IApplicationPaths appPaths, IJsonSerializer json, ILogger logger, IFileSystem fileSystem)
|
||||
{
|
||||
_appPaths = appPaths;
|
||||
_json = json;
|
||||
_logger = logger;
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
private string GetDevicesPath()
|
||||
@@ -129,12 +132,12 @@ namespace MediaBrowser.Server.Implementations.Devices
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Delete(path, true);
|
||||
_fileSystem.DeleteDirectory(path, true);
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
_devices = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using MediaBrowser.Common.ScheduledTasks;
|
||||
using MediaBrowser.Common.Updates;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Net;
|
||||
@@ -44,28 +43,15 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||
/// </summary>
|
||||
private readonly ITaskManager _taskManager;
|
||||
|
||||
private readonly IDtoService _dtoService;
|
||||
|
||||
private readonly ISessionManager _sessionManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ServerEventNotifier" /> class.
|
||||
/// </summary>
|
||||
/// <param name="serverManager">The server manager.</param>
|
||||
/// <param name="appHost">The application host.</param>
|
||||
/// <param name="userManager">The user manager.</param>
|
||||
/// <param name="installationManager">The installation manager.</param>
|
||||
/// <param name="taskManager">The task manager.</param>
|
||||
/// <param name="dtoService">The dto service.</param>
|
||||
/// <param name="sessionManager">The session manager.</param>
|
||||
public ServerEventNotifier(IServerManager serverManager, IServerApplicationHost appHost, IUserManager userManager, IInstallationManager installationManager, ITaskManager taskManager, IDtoService dtoService, ISessionManager sessionManager)
|
||||
public ServerEventNotifier(IServerManager serverManager, IServerApplicationHost appHost, IUserManager userManager, IInstallationManager installationManager, ITaskManager taskManager, ISessionManager sessionManager)
|
||||
{
|
||||
_serverManager = serverManager;
|
||||
_userManager = userManager;
|
||||
_installationManager = installationManager;
|
||||
_appHost = appHost;
|
||||
_taskManager = taskManager;
|
||||
_dtoService = dtoService;
|
||||
_sessionManager = sessionManager;
|
||||
}
|
||||
|
||||
@@ -86,13 +72,6 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||
_taskManager.TaskCompleted += _taskManager_TaskCompleted;
|
||||
}
|
||||
|
||||
void _userManager_UserConfigurationUpdated(object sender, GenericEventArgs<User> e)
|
||||
{
|
||||
var dto = _userManager.GetUserDto(e.Argument);
|
||||
|
||||
_serverManager.SendWebSocketMessage("UserConfigurationUpdated", dto);
|
||||
}
|
||||
|
||||
void _installationManager_PackageInstalling(object sender, InstallationEventArgs e)
|
||||
{
|
||||
_serverManager.SendWebSocketMessage("PackageInstalling", e.InstallationInfo);
|
||||
@@ -146,8 +125,8 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||
void userManager_UserUpdated(object sender, GenericEventArgs<User> e)
|
||||
{
|
||||
var dto = _userManager.GetUserDto(e.Argument);
|
||||
|
||||
_serverManager.SendWebSocketMessage("UserUpdated", dto);
|
||||
|
||||
SendMessageToUserSession(e.Argument, "UserUpdated", dto);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -157,7 +136,19 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||
/// <param name="e">The e.</param>
|
||||
void userManager_UserDeleted(object sender, GenericEventArgs<User> e)
|
||||
{
|
||||
_serverManager.SendWebSocketMessage("UserDeleted", e.Argument.Id.ToString("N"));
|
||||
SendMessageToUserSession(e.Argument, "UserDeleted", e.Argument.Id.ToString("N"));
|
||||
}
|
||||
|
||||
void _userManager_UserConfigurationUpdated(object sender, GenericEventArgs<User> e)
|
||||
{
|
||||
var dto = _userManager.GetUserDto(e.Argument);
|
||||
|
||||
SendMessageToUserSession(e.Argument, "UserConfigurationUpdated", dto);
|
||||
}
|
||||
|
||||
private async void SendMessageToUserSession<T>(User user, string name, T data)
|
||||
{
|
||||
await _sessionManager.SendMessageToUserSessions(user.Id.ToString("N"), name, data, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
|
||||
{
|
||||
var userId = pair.Key;
|
||||
var userSessions = _sessionManager.Sessions
|
||||
.Where(u => u.UserId.HasValue && u.UserId.Value == userId && u.SessionController != null && u.IsActive)
|
||||
.Where(u => u.ContainsUser(userId) && u.SessionController != null && u.IsActive)
|
||||
.ToList();
|
||||
|
||||
if (userSessions.Count > 0)
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||
|
||||
try
|
||||
{
|
||||
File.Delete(path);
|
||||
_fileSystem.DeleteFile(path);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
@@ -315,7 +315,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(result.OriginalPath);
|
||||
_fileSystem.DeleteFile(result.OriginalPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||
_logger.Info("Requested to delete {0}", result.OriginalPath);
|
||||
try
|
||||
{
|
||||
File.Delete(result.OriginalPath);
|
||||
_fileSystem.DeleteFile(result.OriginalPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(file.FullName);
|
||||
_fileSystem.DeleteFile(file.FullName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -556,31 +556,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer.SocketSharp
|
||||
return (stream);
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveAs(string filename)
|
||||
{
|
||||
byte[] buffer = new byte[16 * 1024];
|
||||
long old_post = stream.Position;
|
||||
|
||||
try
|
||||
{
|
||||
File.Delete(filename);
|
||||
using (FileStream fs = File.Create(filename))
|
||||
{
|
||||
stream.Position = 0;
|
||||
int n;
|
||||
|
||||
while ((n = stream.Read(buffer, 0, 16 * 1024)) != 0)
|
||||
{
|
||||
fs.Write(buffer, 0, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
stream.Position = old_post;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Helpers
|
||||
|
||||
@@ -401,11 +401,11 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
try
|
||||
{
|
||||
Directory.Delete(metadataPath, true);
|
||||
_fileSystem.DeleteDirectory(metadataPath, true);
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -420,12 +420,12 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
_logger.Debug("Deleting path {0}", path);
|
||||
Directory.Delete(path, true);
|
||||
_fileSystem.DeleteDirectory(path, true);
|
||||
}
|
||||
else if (File.Exists(path))
|
||||
{
|
||||
_logger.Debug("Deleting path {0}", path);
|
||||
File.Delete(path);
|
||||
_fileSystem.DeleteFile(path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -840,6 +840,23 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return GetItemByName<Year>(ConfigurationManager.ApplicationPaths.YearPath, value.ToString(UsCulture));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the artists path.
|
||||
/// </summary>
|
||||
/// <value>The artists path.</value>
|
||||
public string ArtistsPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ConfigurationManager.Configuration.StoreArtistsInMetadata)
|
||||
{
|
||||
return Path.Combine(ConfigurationManager.ApplicationPaths.InternalMetadataPath, "artists");
|
||||
}
|
||||
|
||||
return Path.Combine(ConfigurationManager.ApplicationPaths.ItemsByNamePath, "artists");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a Genre
|
||||
/// </summary>
|
||||
@@ -847,7 +864,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
/// <returns>Task{Genre}.</returns>
|
||||
public MusicArtist GetArtist(string name)
|
||||
{
|
||||
return GetItemByName<MusicArtist>(ConfigurationManager.ApplicationPaths.ArtistsPath, name);
|
||||
return GetItemByName<MusicArtist>(ArtistsPath, name);
|
||||
}
|
||||
|
||||
private T GetItemByName<T>(string path, string name)
|
||||
@@ -976,7 +993,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
public Task ValidateArtists(CancellationToken cancellationToken, IProgress<double> progress)
|
||||
{
|
||||
// Ensure the location is unavailable.
|
||||
Directory.CreateDirectory(ConfigurationManager.ApplicationPaths.ArtistsPath);
|
||||
Directory.CreateDirectory(ArtistsPath);
|
||||
|
||||
return new ArtistsValidator(this, _userManager, _logger).Run(progress, cancellationToken);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using MediaBrowser.Common.Events;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Channels;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Connect;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
@@ -11,6 +13,7 @@ using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Channels;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Connect;
|
||||
using MediaBrowser.Model.Dto;
|
||||
@@ -69,9 +72,11 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
private readonly Func<IImageProcessor> _imageProcessorFactory;
|
||||
private readonly Func<IDtoService> _dtoServiceFactory;
|
||||
private readonly Func<IConnectManager> _connectFactory;
|
||||
private readonly Func<IChannelManager> _channelManager;
|
||||
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)
|
||||
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)
|
||||
{
|
||||
_logger = logger;
|
||||
UserRepository = userRepository;
|
||||
@@ -82,6 +87,8 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
_connectFactory = connectFactory;
|
||||
_appHost = appHost;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
_fileSystem = fileSystem;
|
||||
_channelManager = channelManager;
|
||||
ConfigurationManager = configurationManager;
|
||||
Users = new List<User>();
|
||||
|
||||
@@ -165,6 +172,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
foreach (var user in users)
|
||||
{
|
||||
await DoPolicyMigration(user).ConfigureAwait(false);
|
||||
await DoChannelMigration(user).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// If there are no local users with admin rights, make them all admins
|
||||
@@ -204,7 +212,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
return username;
|
||||
}
|
||||
|
||||
|
||||
// Usernames can contain letters (a-z), numbers (0-9), dashes (-), underscores (_), apostrophes ('), and periods (.)
|
||||
var builder = new StringBuilder();
|
||||
|
||||
@@ -329,22 +337,12 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
if (!user.Configuration.HasMigratedToPolicy)
|
||||
{
|
||||
user.Policy.AccessSchedules = user.Configuration.AccessSchedules;
|
||||
user.Policy.BlockedChannels = user.Configuration.BlockedChannels;
|
||||
user.Policy.BlockedMediaFolders = user.Configuration.BlockedMediaFolders;
|
||||
user.Policy.BlockedTags = user.Configuration.BlockedTags;
|
||||
user.Policy.BlockUnratedItems = user.Configuration.BlockUnratedItems;
|
||||
user.Policy.EnableContentDeletion = user.Configuration.EnableContentDeletion;
|
||||
user.Policy.EnableLiveTvAccess = user.Configuration.EnableLiveTvAccess;
|
||||
user.Policy.EnableLiveTvManagement = user.Configuration.EnableLiveTvManagement;
|
||||
user.Policy.EnableMediaPlayback = user.Configuration.EnableMediaPlayback;
|
||||
user.Policy.EnableRemoteControlOfOtherUsers = user.Configuration.EnableRemoteControlOfOtherUsers;
|
||||
user.Policy.EnableSharedDeviceControl = user.Configuration.EnableSharedDeviceControl;
|
||||
user.Policy.EnableUserPreferenceAccess = user.Configuration.EnableUserPreferenceAccess;
|
||||
user.Policy.IsAdministrator = user.Configuration.IsAdministrator;
|
||||
user.Policy.IsDisabled = user.Configuration.IsDisabled;
|
||||
user.Policy.IsHidden = user.Configuration.IsHidden;
|
||||
user.Policy.MaxParentalRating = user.Configuration.MaxParentalRating;
|
||||
|
||||
await UpdateUserPolicy(user, user.Policy, false);
|
||||
|
||||
@@ -353,6 +351,44 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DoChannelMigration(User user)
|
||||
{
|
||||
if (user.Policy.BlockedChannels != null)
|
||||
{
|
||||
if (user.Policy.BlockedChannels.Length > 0)
|
||||
{
|
||||
user.Policy.EnableAllChannels = false;
|
||||
|
||||
try
|
||||
{
|
||||
var channelResult = await _channelManager().GetChannelsInternal(new ChannelQuery
|
||||
{
|
||||
UserId = user.Id.ToString("N")
|
||||
|
||||
}, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
user.Policy.EnabledChannels = channelResult.Items
|
||||
.Select(i => i.Id.ToString("N"))
|
||||
.Except(user.Policy.BlockedChannels)
|
||||
.ToArray();
|
||||
}
|
||||
catch
|
||||
{
|
||||
user.Policy.EnabledChannels = new string[] { };
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
user.Policy.EnableAllChannels = true;
|
||||
user.Policy.EnabledChannels = new string[] { };
|
||||
}
|
||||
|
||||
user.Policy.BlockedChannels = null;
|
||||
|
||||
await UpdateUserPolicy(user, user.Policy, false);
|
||||
}
|
||||
}
|
||||
|
||||
public UserDto GetUserDto(User user, string remoteEndPoint = null)
|
||||
{
|
||||
if (user == null)
|
||||
@@ -591,7 +627,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
try
|
||||
{
|
||||
File.Delete(configPath);
|
||||
_fileSystem.DeleteFile(configPath);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
@@ -817,7 +853,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(PasswordResetFile);
|
||||
_fileSystem.DeleteFile(PasswordResetFile);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -881,7 +917,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
var json = _jsonSerializer.SerializeToString(userPolicy);
|
||||
userPolicy = _jsonSerializer.DeserializeFromString<UserPolicy>(json);
|
||||
}
|
||||
|
||||
|
||||
var path = GetPolifyFilePath(user);
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
@@ -909,7 +945,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
lock (_policySyncLock)
|
||||
{
|
||||
File.Delete(path);
|
||||
_fileSystem.DeleteFile(path);
|
||||
}
|
||||
}
|
||||
catch (IOException)
|
||||
@@ -971,14 +1007,14 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
var path = GetConfigurationFilePath(user);
|
||||
|
||||
// The xml serializer will output differently if the type is not exact
|
||||
if (config.GetType() != typeof (UserConfiguration))
|
||||
if (config.GetType() != typeof(UserConfiguration))
|
||||
{
|
||||
var json = _jsonSerializer.SerializeToString(config);
|
||||
config = _jsonSerializer.DeserializeFromString<UserConfiguration>(json);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
|
||||
lock (_configSyncLock)
|
||||
{
|
||||
_xmlSerializer.SerializeToFile(config, path);
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
"LabelFailed": "(failed)",
|
||||
"ButtonHelp": "Help",
|
||||
"ButtonSave": "Save",
|
||||
"HeaderDevices": "Devices",
|
||||
"HeaderSupporterBenefit": "A supporter membership provides additional benefits such as access to premium plugins, internet channel content, and more. {0}Learn more{1}.",
|
||||
"HeaderWelcomeToMediaBrowserServerDashboard": "Welcome to the Media Browser Dashboard",
|
||||
"HeaderWelcomeToMediaBrowserWebClient": "Welcome to the Media Browser Web Client",
|
||||
|
||||
@@ -86,6 +86,7 @@
|
||||
"TabCollectionTitles": "Titles",
|
||||
"HeaderDeviceAccess": "Device Access",
|
||||
"OptionEnableAccessFromAllDevices": "Enable access from all devices",
|
||||
"OptionEnableAccessToAllChannels": "Enable access to all channels",
|
||||
"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",
|
||||
|
||||
@@ -215,7 +215,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
||||
|
||||
try
|
||||
{
|
||||
File.Delete(image);
|
||||
_fileSystem.DeleteFile(image);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
|
||||
@@ -197,19 +197,6 @@ namespace MediaBrowser.Server.Implementations
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the artists path.
|
||||
/// </summary>
|
||||
/// <value>The artists path.</value>
|
||||
public string ArtistsPath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(ItemsByNamePath, "artists");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the game genre path.
|
||||
/// </summary>
|
||||
|
||||
@@ -209,6 +209,12 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
return SendMessage(command.Name, command.Arguments, cancellationToken);
|
||||
}
|
||||
|
||||
public Task SendMessage<T>(string name, T data, CancellationToken cancellationToken)
|
||||
{
|
||||
// Not supported or needed right now
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
private string ToQueryString(Dictionary<string, string> nvc)
|
||||
{
|
||||
var array = (from item in nvc
|
||||
|
||||
@@ -1632,5 +1632,26 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
return Sessions.FirstOrDefault(i => string.Equals(i.DeviceId, deviceId) &&
|
||||
string.Equals(i.Client, client));
|
||||
}
|
||||
|
||||
public Task SendMessageToUserSessions<T>(string userId, string name, T data,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var sessions = Sessions.Where(i => i.IsActive && i.SessionController != null && i.ContainsUser(userId)).ToList();
|
||||
|
||||
var tasks = sessions.Select(session => Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await session.SessionController.SendMessage(name, data, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error in SendPlaybackStoppedNotification.", ex);
|
||||
}
|
||||
|
||||
}, cancellationToken));
|
||||
|
||||
return Task.WhenAll(tasks);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
|
||||
public Task SendPlayCommand(PlayRequest command, CancellationToken cancellationToken)
|
||||
{
|
||||
return SendMessage(new WebSocketMessage<PlayRequest>
|
||||
return SendMessageInternal(new WebSocketMessage<PlayRequest>
|
||||
{
|
||||
MessageType = "Play",
|
||||
Data = command
|
||||
@@ -100,7 +100,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
|
||||
public Task SendPlaystateCommand(PlaystateRequest command, CancellationToken cancellationToken)
|
||||
{
|
||||
return SendMessage(new WebSocketMessage<PlaystateRequest>
|
||||
return SendMessageInternal(new WebSocketMessage<PlaystateRequest>
|
||||
{
|
||||
MessageType = "Playstate",
|
||||
Data = command
|
||||
@@ -110,7 +110,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
|
||||
public Task SendLibraryUpdateInfo(LibraryUpdateInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
return SendMessages(new WebSocketMessage<LibraryUpdateInfo>
|
||||
return SendMessagesInternal(new WebSocketMessage<LibraryUpdateInfo>
|
||||
{
|
||||
MessageType = "LibraryChanged",
|
||||
Data = info
|
||||
@@ -126,7 +126,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
/// <returns>Task.</returns>
|
||||
public Task SendRestartRequiredNotification(SystemInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
return SendMessages(new WebSocketMessage<SystemInfo>
|
||||
return SendMessagesInternal(new WebSocketMessage<SystemInfo>
|
||||
{
|
||||
MessageType = "RestartRequired",
|
||||
Data = info
|
||||
@@ -143,7 +143,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
/// <returns>Task.</returns>
|
||||
public Task SendUserDataChangeInfo(UserDataChangeInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
return SendMessages(new WebSocketMessage<UserDataChangeInfo>
|
||||
return SendMessagesInternal(new WebSocketMessage<UserDataChangeInfo>
|
||||
{
|
||||
MessageType = "UserDataChanged",
|
||||
Data = info
|
||||
@@ -158,7 +158,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
/// <returns>Task.</returns>
|
||||
public Task SendServerShutdownNotification(CancellationToken cancellationToken)
|
||||
{
|
||||
return SendMessages(new WebSocketMessage<string>
|
||||
return SendMessagesInternal(new WebSocketMessage<string>
|
||||
{
|
||||
MessageType = "ServerShuttingDown",
|
||||
Data = string.Empty
|
||||
@@ -173,7 +173,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
/// <returns>Task.</returns>
|
||||
public Task SendServerRestartNotification(CancellationToken cancellationToken)
|
||||
{
|
||||
return SendMessages(new WebSocketMessage<string>
|
||||
return SendMessagesInternal(new WebSocketMessage<string>
|
||||
{
|
||||
MessageType = "ServerRestarting",
|
||||
Data = string.Empty
|
||||
@@ -183,7 +183,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
|
||||
public Task SendGeneralCommand(GeneralCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
return SendMessage(new WebSocketMessage<GeneralCommand>
|
||||
return SendMessageInternal(new WebSocketMessage<GeneralCommand>
|
||||
{
|
||||
MessageType = "GeneralCommand",
|
||||
Data = command
|
||||
@@ -193,7 +193,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
|
||||
public Task SendSessionEndedNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return SendMessages(new WebSocketMessage<SessionInfoDto>
|
||||
return SendMessagesInternal(new WebSocketMessage<SessionInfoDto>
|
||||
{
|
||||
MessageType = "SessionEnded",
|
||||
Data = sessionInfo
|
||||
@@ -203,7 +203,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
|
||||
public Task SendPlaybackStartNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return SendMessages(new WebSocketMessage<SessionInfoDto>
|
||||
return SendMessagesInternal(new WebSocketMessage<SessionInfoDto>
|
||||
{
|
||||
MessageType = "PlaybackStart",
|
||||
Data = sessionInfo
|
||||
@@ -213,7 +213,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
|
||||
public Task SendPlaybackStoppedNotification(SessionInfoDto sessionInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return SendMessages(new WebSocketMessage<SessionInfoDto>
|
||||
return SendMessagesInternal(new WebSocketMessage<SessionInfoDto>
|
||||
{
|
||||
MessageType = "PlaybackStopped",
|
||||
Data = sessionInfo
|
||||
@@ -221,7 +221,17 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
private Task SendMessage<T>(WebSocketMessage<T> message, CancellationToken cancellationToken)
|
||||
public Task SendMessage<T>(string name, T data, CancellationToken cancellationToken)
|
||||
{
|
||||
return SendMessagesInternal(new WebSocketMessage<T>
|
||||
{
|
||||
Data = data,
|
||||
MessageType = name
|
||||
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
private Task SendMessageInternal<T>(WebSocketMessage<T> message, CancellationToken cancellationToken)
|
||||
{
|
||||
if (SkipSending()) return Task.FromResult(true);
|
||||
|
||||
@@ -230,7 +240,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
return socket.SendAsync(message, cancellationToken);
|
||||
}
|
||||
|
||||
private Task SendMessages<T>(WebSocketMessage<T> message, CancellationToken cancellationToken)
|
||||
private Task SendMessagesInternal<T>(WebSocketMessage<T> message, CancellationToken cancellationToken)
|
||||
{
|
||||
if (SkipSending()) return Task.FromResult(true);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using MediaBrowser.Common;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Controller.Channels;
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
@@ -37,10 +38,11 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
private readonly IApplicationHost _appHost;
|
||||
private readonly ITVSeriesManager _tvSeriesManager;
|
||||
private readonly Func<IMediaEncoder> _mediaEncoder;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
private ISyncProvider[] _providers = { };
|
||||
|
||||
public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, Func<IDtoService> dtoService, IApplicationHost appHost, ITVSeriesManager tvSeriesManager, Func<IMediaEncoder> mediaEncoder)
|
||||
public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, Func<IDtoService> dtoService, IApplicationHost appHost, ITVSeriesManager tvSeriesManager, Func<IMediaEncoder> mediaEncoder, IFileSystem fileSystem)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_repo = repo;
|
||||
@@ -51,6 +53,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
_appHost = appHost;
|
||||
_tvSeriesManager = tvSeriesManager;
|
||||
_mediaEncoder = mediaEncoder;
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
public void AddParts(IEnumerable<ISyncProvider> providers)
|
||||
@@ -396,7 +399,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(jobItem.OutputPath);
|
||||
_fileSystem.DeleteFile(jobItem.OutputPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace MediaBrowser.Server.Implementations.Sync
|
||||
|
||||
public bool IsHidden
|
||||
{
|
||||
get { return true; }
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public bool IsEnabled
|
||||
|
||||
Reference in New Issue
Block a user