The Free Software Media System - Server Backend & API
Merge branch 'master' into userdb-efcore
Patrick Barronaca7e221d811
diff --cc Emby.Server.Implementations/Activity/ActivityLogEntryPoint.csindex 3d38590782,3983824a3e..31d9609a69--- a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs+++ b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs@@@ -93,41 -88,24 +88,23 @@@ namespace Emby.Server.Implementations.A_subManager.SubtitleDownloadFailure += OnSubtitleDownloadFailure;- _userManager.UserCreated += OnUserCreated;- _userManager.UserPasswordChanged += OnUserPasswordChanged;- _userManager.UserDeleted += OnUserDeleted;- _userManager.UserPolicyUpdated += OnUserPolicyUpdated;- _userManager.UserLockedOut += OnUserLockedOut;+ _userManager.OnUserCreated += OnUserCreated;+ _userManager.OnUserPasswordChanged += OnUserPasswordChanged;+ _userManager.OnUserDeleted += OnUserDeleted;+ _userManager.OnUserLockedOut += OnUserLockedOut;- _deviceManager.CameraImageUploaded += OnCameraImageUploaded;-return Task.CompletedTask;}- private async void OnCameraImageUploaded(object sender, GenericEventArgs<CameraImageUploadInfo> e)- {- await CreateLogEntry(new ActivityLog(- string.Format(- CultureInfo.InvariantCulture,- _localization.GetLocalizedString("CameraImageUploadedFrom"),- e.Argument.Device.Name),- NotificationType.CameraImageUploaded.ToString(),- Guid.Empty,- DateTime.UtcNow,- LogLevel.Trace))- .ConfigureAwait(false);- }-- private async void OnUserLockedOut(object sender, GenericEventArgs<MediaBrowser.Controller.Entities.User> e)+ private async void OnUserLockedOut(object sender, GenericEventArgs<User> e){await CreateLogEntry(new ActivityLog(- string.Format(- CultureInfo.InvariantCulture,- _localization.GetLocalizedString("UserLockedOutWithName"),- e.Argument.Username),- NotificationType.UserLockedOut.ToString(),- e.Argument.Id,- DateTime.UtcNow,- LogLevel.Trace))+ string.Format(+ CultureInfo.InvariantCulture,+ _localization.GetLocalizedString("UserLockedOutWithName"),- e.Argument.Name),++ e.Argument.Username),+ NotificationType.UserLockedOut.ToString(),+ e.Argument.Id)).ConfigureAwait(false);}@@@ -343,11 -310,9 +309,9 @@@string.Format(CultureInfo.InvariantCulture,_localization.GetLocalizedString("UserPolicyUpdatedWithName"),- e.Argument.Name),+ e.Argument.Username),"UserPolicyUpdated",- e.Argument.Id,- DateTime.UtcNow,- LogLevel.Trace))+ e.Argument.Id)).ConfigureAwait(false);}@@@ -357,11 -322,9 +321,9 @@@string.Format(CultureInfo.InvariantCulture,_localization.GetLocalizedString("UserDeletedWithName"),- e.Argument.Name),+ e.Argument.Username),"UserDeleted",- Guid.Empty,- DateTime.UtcNow,- LogLevel.Trace))+ Guid.Empty)).ConfigureAwait(false);}@@@ -371,24 -334,21 +333,21 @@@string.Format(CultureInfo.InvariantCulture,_localization.GetLocalizedString("UserPasswordChangedWithName"),- e.Argument.Name),+ e.Argument.Username),"UserPasswordChanged",- e.Argument.Id,- DateTime.UtcNow,- LogLevel.Trace)).ConfigureAwait(false);+ e.Argument.Id))+ .ConfigureAwait(false);}- private async void OnUserCreated(object sender, GenericEventArgs<MediaBrowser.Controller.Entities.User> e)+ private async void OnUserCreated(object sender, GenericEventArgs<User> e){await CreateLogEntry(new ActivityLog(string.Format(CultureInfo.InvariantCulture,_localization.GetLocalizedString("UserCreatedWithName"),- e.Argument.Name),+ e.Argument.Username),"UserCreated",- e.Argument.Id,- DateTime.UtcNow,- LogLevel.Trace))+ e.Argument.Id)).ConfigureAwait(false);}@@@ -561,12 -510,11 +509,10 @@@_subManager.SubtitleDownloadFailure -= OnSubtitleDownloadFailure;- _userManager.UserCreated -= OnUserCreated;- _userManager.UserPasswordChanged -= OnUserPasswordChanged;- _userManager.UserDeleted -= OnUserDeleted;- _userManager.UserPolicyUpdated -= OnUserPolicyUpdated;- _userManager.UserLockedOut -= OnUserLockedOut;+ _userManager.OnUserCreated -= OnUserCreated;+ _userManager.OnUserPasswordChanged -= OnUserPasswordChanged;+ _userManager.OnUserDeleted -= OnUserDeleted;+ _userManager.OnUserLockedOut -= OnUserLockedOut;-- _deviceManager.CameraImageUploaded -= OnCameraImageUploaded;}/// <summary>diff --cc Emby.Server.Implementations/ApplicationHost.csindex 06cc51c42f,e6410f8570..b2fe6a3ab7--- a/Emby.Server.Implementations/ApplicationHost.cs+++ b/Emby.Server.Implementations/ApplicationHost.cs@@@ -697,7 -653,9 +651,8 @@@ namespace Emby.Server.Implementation_httpServer = Resolve<IHttpServer>();_httpClient = Resolve<IHttpClient>();+ ((SqliteDisplayPreferencesRepository)Resolve<IDisplayPreferencesRepository>()).Initialize();((AuthenticationRepository)Resolve<IAuthenticationRepository>()).Initialize();- ((SqliteUserRepository)Resolve<IUserRepository>()).Initialize();SetStaticProperties();diff --cc Emby.Server.Implementations/Devices/DeviceManager.csindex d6bce93f84,2283f2433a..2d44a7c28d--- a/Emby.Server.Implementations/Devices/DeviceManager.cs+++ b/Emby.Server.Implementations/Devices/DeviceManager.cs@@@ -5,9 -5,6 +5,9 @@@ using System.Collections.Genericusing System.Globalization;using System.IO;using System.Linq;+using System.Threading.Tasks;+using Jellyfin.Data.Enums;- using MediaBrowser.Common.Configuration;++using Jellyfin.Data.Entities;using MediaBrowser.Common.Extensions;using MediaBrowser.Controller.Configuration;using MediaBrowser.Controller.Devices;@@@ -390,103 -193,20 +202,5 @@@ namespace Emby.Server.Implementations.Dreturn true;}-- private static bool CanAccessDevice(UserPolicy policy, string id)- {- if (policy.EnableAllDevices)- {- return true;- }-- if (policy.IsAdministrator)- {- return true;- }-- return policy.EnabledDevices.Contains(id, StringComparer.OrdinalIgnoreCase);- }}-- public class DeviceManagerEntryPoint : IServerEntryPoint- {- private readonly DeviceManager _deviceManager;- private readonly IServerConfigurationManager _config;- private ILogger _logger;-- public DeviceManagerEntryPoint(- IDeviceManager deviceManager,- IServerConfigurationManager config,- ILogger<DeviceManagerEntryPoint> logger)- {- _deviceManager = (DeviceManager)deviceManager;- _config = config;- _logger = logger;- }-- public async Task RunAsync()- {- if (!_config.Configuration.CameraUploadUpgraded && _config.Configuration.IsStartupWizardCompleted)- {- var path = _deviceManager.GetUploadsPath();-- if (Directory.Exists(path))- {- try- {- await _deviceManager.EnsureLibraryFolder(path, null).ConfigureAwait(false);- }- catch (Exception ex)- {- _logger.LogError(ex, "Error creating camera uploads library");- }-- _config.Configuration.CameraUploadUpgraded = true;- _config.SaveConfiguration();- }- }- }-- #region IDisposable Support- private bool disposedValue = false; // To detect redundant calls-- protected virtual void Dispose(bool disposing)- {- if (!disposedValue)- {- if (disposing)- {- // TODO: dispose managed state (managed objects).- }-- // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.- // TODO: set large fields to null.-- disposedValue = true;- }- }-- // TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.- // ~DeviceManagerEntryPoint() {- // // Do not change this code. Put cleanup code in Dispose(bool disposing) above.- // Dispose(false);- // }-- // This code added to correctly implement the disposable pattern.- public void Dispose()- {- // Do not change this code. Put cleanup code in Dispose(bool disposing) above.- Dispose(true);- // TODO: uncomment the following line if the finalizer is overridden above.- // GC.SuppressFinalize(this);- }- #endregion- }-- public class DevicesConfigStore : IConfigurationFactory- {- public IEnumerable<ConfigurationStore> GetConfigurations()- {- return new ConfigurationStore[]- {- new ConfigurationStore- {- Key = "devices",- ConfigurationType = typeof(DevicesOptions)- }- };- }- }-- public static class UploadConfigExtension- {- public static DevicesOptions GetUploadOptions(this IConfigurationManager config)- {- return config.GetConfiguration<DevicesOptions>("devices");- }- }}diff --cc Emby.Server.Implementations/Session/SessionManager.csindex d595e96bda,df98a35bc0..84b16f1c7a--- a/Emby.Server.Implementations/Session/SessionManager.cs+++ b/Emby.Server.Implementations/Session/SessionManager.cs@@@ -490,11 -477,10 +490,10 @@@ namespace Emby.Server.Implementations.SClient = appName,DeviceId = deviceId,ApplicationVersion = appVersion,- Id = key.GetMD5().ToString("N", CultureInfo.InvariantCulture),- ServerId = _appHost.SystemId+ Id = key.GetMD5().ToString("N", CultureInfo.InvariantCulture)};- var username = user?.Name;+ var username = user?.Username;sessionInfo.UserId = user?.Id ?? Guid.Empty;sessionInfo.UserName = username;diff --cc Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csprojindex 7ff9786980,149ca50209..09310f98c6--- a/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj+++ b/Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj@@@ -23,10 -23,16 +23,18 @@@<Compile Include="..\SharedVersion.cs" /><Compile Remove="Migrations\20200430214405_InitialSchema.cs" /><Compile Remove="Migrations\20200430214405_InitialSchema.Designer.cs" />+ <Compile Remove="Migrations\20200504195424_UserSchema.cs" />+ <Compile Remove="Migrations\20200504195424_UserSchema.Designer.cs" /></ItemGroup>+ <ItemGroup>+ <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.3" />+ <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.3">+ <PrivateAssets>all</PrivateAssets>+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>+ </PackageReference>+ </ItemGroup>+<ItemGroup><ProjectReference Include="..\Jellyfin.Data\Jellyfin.Data.csproj" /><ProjectReference Include="..\MediaBrowser.Controller\MediaBrowser.Controller.csproj" />diff --cc Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.csindex d3a7ed3334,1e7ffd2359..0fb0ba8033--- a/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs+++ b/Jellyfin.Server.Implementations/Migrations/JellyfinDbModelSnapshot.cs@@@ -60,259 -58,8 +58,259 @@@ namespace Jellyfin.Server.Implementatiob.HasKey("Id");- b.ToTable("ActivityLog");+ b.ToTable("ActivityLogs");});++ modelBuilder.Entity("Jellyfin.Data.Entities.Group", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<int?>("Group_Groups_Id")+ .HasColumnType("INTEGER");++ b.Property<string>("Name")+ .IsRequired()+ .HasColumnType("TEXT")+ .HasMaxLength(255);++ b.Property<uint>("RowVersion")+ .IsConcurrencyToken()+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("Group_Groups_Id");++ b.ToTable("Group");+ });++ modelBuilder.Entity("Jellyfin.Data.Entities.Permission", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<int>("Kind")+ .HasColumnType("INTEGER");++ b.Property<int?>("Permission_GroupPermissions_Id")+ .HasColumnType("INTEGER");++ b.Property<int?>("Permission_Permissions_Id")+ .HasColumnType("INTEGER");++ b.Property<uint>("RowVersion")+ .IsConcurrencyToken()+ .HasColumnType("INTEGER");++ b.Property<bool>("Value")+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("Permission_GroupPermissions_Id");++ b.HasIndex("Permission_Permissions_Id");++ b.ToTable("Permission");+ });++ modelBuilder.Entity("Jellyfin.Data.Entities.Preference", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<int>("Kind")+ .HasColumnType("INTEGER");++ b.Property<int?>("Preference_Preferences_Id")+ .HasColumnType("INTEGER");++ b.Property<uint>("RowVersion")+ .IsConcurrencyToken()+ .HasColumnType("INTEGER");++ b.Property<string>("Value")+ .IsRequired()+ .HasColumnType("TEXT")+ .HasMaxLength(65535);++ b.HasKey("Id");++ b.HasIndex("Preference_Preferences_Id");++ b.ToTable("Preference");+ });++ modelBuilder.Entity("Jellyfin.Data.Entities.ProviderMapping", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("ProviderData")+ .IsRequired()+ .HasColumnType("TEXT")+ .HasMaxLength(65535);++ b.Property<int?>("ProviderMapping_ProviderMappings_Id")+ .HasColumnType("INTEGER");++ b.Property<string>("ProviderName")+ .IsRequired()+ .HasColumnType("TEXT")+ .HasMaxLength(255);++ b.Property<string>("ProviderSecrets")+ .IsRequired()+ .HasColumnType("TEXT")+ .HasMaxLength(65535);++ b.Property<uint>("RowVersion")+ .IsConcurrencyToken()+ .HasColumnType("INTEGER");++ b.HasKey("Id");++ b.HasIndex("ProviderMapping_ProviderMappings_Id");++ b.ToTable("ProviderMapping");+ });++ modelBuilder.Entity("Jellyfin.Data.Entities.User", b =>+ {+ b.Property<int>("Id")+ .ValueGeneratedOnAdd()+ .HasColumnType("INTEGER");++ b.Property<string>("AudioLanguagePreference")+ .IsRequired()+ .HasColumnType("TEXT")+ .HasMaxLength(255);++ b.Property<string>("AuthenticationProviderId")+ .IsRequired()+ .HasColumnType("TEXT")+ .HasMaxLength(255);++ b.Property<bool?>("DisplayCollectionsView")+ .HasColumnType("INTEGER");++ b.Property<bool?>("DisplayMissingEpisodes")+ .HasColumnType("INTEGER");++ b.Property<bool?>("EnableNextEpisodeAutoPlay")+ .HasColumnType("INTEGER");++ b.Property<bool?>("EnableUserPreferenceAccess")+ .HasColumnType("INTEGER");++ b.Property<string>("GroupedFolders")+ .HasColumnType("TEXT")+ .HasMaxLength(65535);++ b.Property<bool?>("HidePlayedInLatest")+ .HasColumnType("INTEGER");++ b.Property<int>("InvalidLoginAttemptCount")+ .HasColumnType("INTEGER");++ b.Property<string>("LatestItemExcludes")+ .HasColumnType("TEXT")+ .HasMaxLength(65535);++ b.Property<int?>("LoginAttemptsBeforeLockout")+ .HasColumnType("INTEGER");++ b.Property<bool>("MustUpdatePassword")+ .HasColumnType("INTEGER");++ b.Property<string>("MyMediaExcludes")+ .HasColumnType("TEXT")+ .HasMaxLength(65535);++ b.Property<string>("OrderedViews")+ .HasColumnType("TEXT")+ .HasMaxLength(65535);++ b.Property<string>("Password")+ .HasColumnType("TEXT")+ .HasMaxLength(65535);++ b.Property<bool>("PlayDefaultAudioTrack")+ .HasColumnType("INTEGER");++ b.Property<bool?>("RememberAudioSelections")+ .HasColumnType("INTEGER");++ b.Property<bool?>("RememberSubtitleSelections")+ .HasColumnType("INTEGER");++ b.Property<uint>("RowVersion")+ .IsConcurrencyToken()+ .HasColumnType("INTEGER");++ b.Property<string>("SubtitleLanguagePrefernce")+ .HasColumnType("TEXT")+ .HasMaxLength(255);++ b.Property<string>("SubtitleMode")+ .IsRequired()+ .HasColumnType("TEXT")+ .HasMaxLength(255);++ b.Property<string>("Username")+ .IsRequired()+ .HasColumnType("TEXT")+ .HasMaxLength(255);++ b.HasKey("Id");++ b.ToTable("User");+ });++ modelBuilder.Entity("Jellyfin.Data.Entities.Group", b =>+ {+ b.HasOne("Jellyfin.Data.Entities.User", null)+ .WithMany("Groups")+ .HasForeignKey("Group_Groups_Id");+ });++ modelBuilder.Entity("Jellyfin.Data.Entities.Permission", b =>+ {+ b.HasOne("Jellyfin.Data.Entities.Group", null)+ .WithMany("GroupPermissions")+ .HasForeignKey("Permission_GroupPermissions_Id");++ b.HasOne("Jellyfin.Data.Entities.User", null)+ .WithMany("Permissions")+ .HasForeignKey("Permission_Permissions_Id");+ });++ modelBuilder.Entity("Jellyfin.Data.Entities.Preference", b =>+ {+ b.HasOne("Jellyfin.Data.Entities.Group", null)+ .WithMany("Preferences")+ .HasForeignKey("Preference_Preferences_Id");++ b.HasOne("Jellyfin.Data.Entities.User", null)+ .WithMany("Preferences")+ .HasForeignKey("Preference_Preferences_Id");+ });++ modelBuilder.Entity("Jellyfin.Data.Entities.ProviderMapping", b =>+ {+ b.HasOne("Jellyfin.Data.Entities.Group", null)+ .WithMany("ProviderMappings")+ .HasForeignKey("ProviderMapping_ProviderMappings_Id");++ b.HasOne("Jellyfin.Data.Entities.User", null)+ .WithMany("ProviderMappings")+ .HasForeignKey("ProviderMapping_ProviderMappings_Id");+ });#pragma warning restore 612, 618}}diff --cc Jellyfin.Server/Jellyfin.Server.csprojindex 51b2a8cc62,9eec6ed4eb..ea16c55730--- a/Jellyfin.Server/Jellyfin.Server.csproj+++ b/Jellyfin.Server/Jellyfin.Server.csproj@@@ -44,11 -41,6 +41,7 @@@<ItemGroup><PackageReference Include="CommandLineParser" Version="2.7.82" />+ <PackageReference Include="Json.Net" Version="1.0.22" />- <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.3">- <PrivateAssets>all</PrivateAssets>- <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>- </PackageReference><PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.3" /><PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.3" /><PackageReference Include="prometheus-net" Version="3.5.0" />diff --cc Jellyfin.Server/Migrations/MigrationRunner.csindex fb793a7cf1,473f62737e..c98263223f--- a/Jellyfin.Server/Migrations/MigrationRunner.cs+++ b/Jellyfin.Server/Migrations/MigrationRunner.cs@@@ -19,7 -19,7 +19,8 @@@ namespace Jellyfin.Server.Migrationtypeof(Routines.DisableTranscodingThrottling),typeof(Routines.CreateUserLoggingConfigFile),typeof(Routines.MigrateActivityLogDb),- typeof(Routines.RemoveDuplicateExtras)++ typeof(Routines.RemoveDuplicateExtras),+ typeof(Routines.MigrateUserDb)};/// <summary>diff --cc MediaBrowser.Api/Library/LibraryService.csindex 783fc6073d,c0146dfee6..50977c48fd--- a/MediaBrowser.Api/Library/LibraryService.cs+++ b/MediaBrowser.Api/Library/LibraryService.cs@@@ -760,11 -764,9 +764,9 @@@ namespace MediaBrowser.Api.Librartry{_activityManager.Create(new Jellyfin.Data.Entities.ActivityLog(- string.Format(_localization.GetLocalizedString("UserDownloadingItemWithValues"), user.Name, item.Name),+ string.Format(_localization.GetLocalizedString("UserDownloadingItemWithValues"), user.Username, item.Name),"UserDownloadingContent",- auth.UserId,- DateTime.UtcNow,- LogLevel.Trace)+ auth.UserId){ShortOverview = string.Format(_localization.GetLocalizedString("AppDeviceValues"), auth.Client, auth.Device),});diff --cc MediaBrowser.Controller/Devices/IDeviceManager.csindex 117af110a0,ef3f43c759..7d279230b5--- a/MediaBrowser.Controller/Devices/IDeviceManager.cs+++ b/MediaBrowser.Controller/Devices/IDeviceManager.cs@@@ -1,7 -1,5 +1,5 @@@using System;- using System.IO;- using System.Threading.Tasks;-using MediaBrowser.Controller.Entities;+using Jellyfin.Data.Entities;using MediaBrowser.Model.Devices;using MediaBrowser.Model.Events;using MediaBrowser.Model.Querying;