The Free Software Media System - Server Backend & API
Fix merge conflicts with SyncPlay
Patrick Barron7c823464bca7
diff --git a/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs b/Emby.Server.Implementations/SyncPlay/SyncPlayManager.csindex 1f76dd4e36..6a3e684ca2 100644--- a/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs+++ b/Emby.Server.Implementations/SyncPlay/SyncPlayManager.cs@@ -3,13 +3,14 @@ using System.Collections.Generic;using System.Globalization;using System.Linq;using System.Threading;-using Microsoft.Extensions.Logging;-using MediaBrowser.Controller.Entities;+using Jellyfin.Data.Entities;+using Jellyfin.Data.Enums;using MediaBrowser.Controller.Library;using MediaBrowser.Controller.Session;using MediaBrowser.Controller.SyncPlay;using MediaBrowser.Model.Configuration;using MediaBrowser.Model.SyncPlay;+using Microsoft.Extensions.Logging;namespace Emby.Server.Implementations.SyncPlay{@@ -102,14 +103,6 @@ namespace Emby.Server.Implementations.SyncPlay_disposed = true;}- private void CheckDisposed()- {- if (_disposed)- {- throw new ObjectDisposedException(GetType().Name);- }- }-private void OnSessionManagerSessionEnded(object sender, SessionEventArgs e){var session = e.SessionInfo;@@ -143,37 +136,26 @@ namespace Emby.Server.Implementations.SyncPlay// Check ParentalRating accessvar hasParentalRatingAccess = true;- if (user.Policy.MaxParentalRating.HasValue)+ if (user.MaxParentalAgeRating.HasValue){- hasParentalRatingAccess = item.InheritedParentalRatingValue <= user.Policy.MaxParentalRating;+ hasParentalRatingAccess = item.InheritedParentalRatingValue <= user.MaxParentalAgeRating.Value;}- if (!user.Policy.EnableAllFolders && hasParentalRatingAccess)+ if (!user.HasPermission(PermissionKind.EnableAllFolders) && hasParentalRatingAccess){var collections = _libraryManager.GetCollectionFolders(item).Select(- folder => folder.Id.ToString("N", CultureInfo.InvariantCulture)- );- var intersect = collections.Intersect(user.Policy.EnabledFolders);- return intersect.Any();- }- else- {- return hasParentalRatingAccess;+ folder => folder.Id.ToString("N", CultureInfo.InvariantCulture));++ return collections.Intersect(user.GetPreference(PreferenceKind.EnabledFolders)).Any();}++ return hasParentalRatingAccess;}private Guid? GetSessionGroup(SessionInfo session){- ISyncPlayController group;- _sessionToGroupMap.TryGetValue(session.Id, out group);- if (group != null)- {- return group.GetGroupId();- }- else- {- return null;- }+ _sessionToGroupMap.TryGetValue(session.Id, out var group);+ return group?.GetGroupId();}/// <inheritdoc />@@ -181,7 +163,7 @@ namespace Emby.Server.Implementations.SyncPlay{var user = _userManager.GetUserById(session.UserId);- if (user.Policy.SyncPlayAccess != SyncPlayAccess.CreateAndJoinGroups)+ if (user.SyncPlayAccess != SyncPlayAccess.CreateAndJoinGroups){_logger.LogWarning("NewGroup: {0} does not have permission to create groups.", session.Id);@@ -189,7 +171,7 @@ namespace Emby.Server.Implementations.SyncPlay{Type = GroupUpdateType.CreateGroupDenied};- _sessionManager.SendSyncPlayGroupUpdate(session.Id.ToString(), error, CancellationToken.None);+ _sessionManager.SendSyncPlayGroupUpdate(session.Id, error, CancellationToken.None);return;}@@ -212,7 +194,7 @@ namespace Emby.Server.Implementations.SyncPlay{var user = _userManager.GetUserById(session.UserId);- if (user.Policy.SyncPlayAccess == SyncPlayAccess.None)+ if (user.SyncPlayAccess == SyncPlayAccess.None){_logger.LogWarning("JoinGroup: {0} does not have access to SyncPlay.", session.Id);@@ -220,7 +202,7 @@ namespace Emby.Server.Implementations.SyncPlay{Type = GroupUpdateType.JoinGroupDenied};- _sessionManager.SendSyncPlayGroupUpdate(session.Id.ToString(), error, CancellationToken.None);+ _sessionManager.SendSyncPlayGroupUpdate(session.Id, error, CancellationToken.None);return;}@@ -237,7 +219,7 @@ namespace Emby.Server.Implementations.SyncPlay{Type = GroupUpdateType.GroupDoesNotExist};- _sessionManager.SendSyncPlayGroupUpdate(session.Id.ToString(), error, CancellationToken.None);+ _sessionManager.SendSyncPlayGroupUpdate(session.Id, error, CancellationToken.None);return;}@@ -250,7 +232,7 @@ namespace Emby.Server.Implementations.SyncPlayGroupId = group.GetGroupId().ToString(),Type = GroupUpdateType.LibraryAccessDenied};- _sessionManager.SendSyncPlayGroupUpdate(session.Id.ToString(), error, CancellationToken.None);+ _sessionManager.SendSyncPlayGroupUpdate(session.Id, error, CancellationToken.None);return;}@@ -285,7 +267,7 @@ namespace Emby.Server.Implementations.SyncPlay{Type = GroupUpdateType.NotInGroup};- _sessionManager.SendSyncPlayGroupUpdate(session.Id.ToString(), error, CancellationToken.None);+ _sessionManager.SendSyncPlayGroupUpdate(session.Id, error, CancellationToken.None);return;}@@ -304,7 +286,7 @@ namespace Emby.Server.Implementations.SyncPlay{var user = _userManager.GetUserById(session.UserId);- if (user.Policy.SyncPlayAccess == SyncPlayAccess.None)+ if (user.SyncPlayAccess == SyncPlayAccess.None){return new List<GroupInfoView>();}@@ -334,7 +316,7 @@ namespace Emby.Server.Implementations.SyncPlay{var user = _userManager.GetUserById(session.UserId);- if (user.Policy.SyncPlayAccess == SyncPlayAccess.None)+ if (user.SyncPlayAccess == SyncPlayAccess.None){_logger.LogWarning("HandleRequest: {0} does not have access to SyncPlay.", session.Id);@@ -342,7 +324,7 @@ namespace Emby.Server.Implementations.SyncPlay{Type = GroupUpdateType.JoinGroupDenied};- _sessionManager.SendSyncPlayGroupUpdate(session.Id.ToString(), error, CancellationToken.None);+ _sessionManager.SendSyncPlayGroupUpdate(session.Id, error, CancellationToken.None);return;}diff --git a/Jellyfin.Data/Entities/User.cs b/Jellyfin.Data/Entities/User.csindex 2287d802b5..0a46617809 100644--- a/Jellyfin.Data/Entities/User.cs+++ b/Jellyfin.Data/Entities/User.cs@@ -61,6 +61,7 @@ namespace Jellyfin.Data.EntitiesEnableAutoLogin = false;PlayDefaultAudioTrack = true;SubtitleMode = SubtitlePlaybackMode.Default;+ SyncPlayAccess = SyncPlayAccess.CreateAndJoinGroups;AddDefaultPermissions();AddDefaultPreferences();@@ -319,6 +320,9 @@ namespace Jellyfin.Data.Entities/// </summary>public virtual ImageInfo ProfileImage { get; set; }+ [Required]+ public SyncPlayAccess SyncPlayAccess { get; set; }+/// <summary>/// Gets or sets the row version./// </summary>diff --git a/MediaBrowser.Model/Configuration/SyncplayAccess.cs b/Jellyfin.Data/Enums/SyncPlayAccess.cssimilarity index 79%rename from MediaBrowser.Model/Configuration/SyncplayAccess.csrename to Jellyfin.Data/Enums/SyncPlayAccess.csindex d891a8167a..8c13b37a13 100644--- a/MediaBrowser.Model/Configuration/SyncplayAccess.cs+++ b/Jellyfin.Data/Enums/SyncPlayAccess.cs@@ -1,4 +1,4 @@-namespace MediaBrowser.Model.Configuration+namespace Jellyfin.Data.Enums{/// <summary>/// Enum SyncPlayAccess.@@ -8,16 +8,16 @@ namespace MediaBrowser.Model.Configuration/// <summary>/// User can create groups and join them./// </summary>- CreateAndJoinGroups,+ CreateAndJoinGroups = 0,/// <summary>/// User can only join already existing groups./// </summary>- JoinGroups,+ JoinGroups = 1,/// <summary>/// SyncPlay is disabled for the user./// </summary>- None+ None = 2}}diff --git a/Jellyfin.Server.Implementations/Users/UserManager.cs b/Jellyfin.Server.Implementations/Users/UserManager.csindex 41116c2512..886c08b4c5 100644--- a/Jellyfin.Server.Implementations/Users/UserManager.cs+++ b/Jellyfin.Server.Implementations/Users/UserManager.cs@@ -352,34 +352,12 @@ namespace Jellyfin.Server.Implementations.UsersEnabledChannels = user.GetPreference(PreferenceKind.EnabledChannels),EnabledDevices = user.GetPreference(PreferenceKind.EnabledDevices),EnabledFolders = user.GetPreference(PreferenceKind.EnabledFolders),- EnableContentDeletionFromFolders = user.GetPreference(PreferenceKind.EnableContentDeletionFromFolders)+ EnableContentDeletionFromFolders = user.GetPreference(PreferenceKind.EnableContentDeletionFromFolders),+ SyncPlayAccess = user.SyncPlayAccess}};}- /// <inheritdoc/>- public PublicUserDto GetPublicUserDto(User user, string remoteEndPoint = null)- {- if (user == null)- {- throw new ArgumentNullException(nameof(user));- }-- bool hasConfiguredPassword = GetAuthenticationProvider(user).HasPassword(user);- bool hasConfiguredEasyPassword = !string.IsNullOrEmpty(GetAuthenticationProvider(user).GetEasyPasswordHash(user));-- bool hasPassword = user.EnableLocalPassword &&- !string.IsNullOrEmpty(remoteEndPoint) &&- _networkManager.IsInLocalNetwork(remoteEndPoint) ? hasConfiguredEasyPassword : hasConfiguredPassword;-- return new PublicUserDto- {- Name = user.Username,- HasPassword = hasPassword,- HasConfiguredPassword = hasConfiguredPassword- };- }-/// <inheritdoc/>public async Task<User> AuthenticateUser(string username,@@ -635,6 +613,7 @@ namespace Jellyfin.Server.Implementations.Usersuser.PasswordResetProviderId = policy.PasswordResetProviderId;user.InvalidLoginAttemptCount = policy.InvalidLoginAttemptCount;user.LoginAttemptsBeforeLockout = maxLoginAttempts;+ user.SyncPlayAccess = policy.SyncPlayAccess;user.SetPermission(PermissionKind.IsAdministrator, policy.IsAdministrator);user.SetPermission(PermissionKind.IsHidden, policy.IsHidden);user.SetPermission(PermissionKind.IsDisabled, policy.IsDisabled);diff --git a/MediaBrowser.Model/Users/UserPolicy.cs b/MediaBrowser.Model/Users/UserPolicy.csindex 7ac63a0aca..66e5529e3a 100644--- a/MediaBrowser.Model/Users/UserPolicy.cs+++ b/MediaBrowser.Model/Users/UserPolicy.cs@@ -1,10 +1,10 @@#pragma warning disable CS1591using System;-using System.Text.Json.Serialization;using System.Xml.Serialization;-using Jellyfin.Data.Entities;using Jellyfin.Data.Enums;+using MediaBrowser.Model.Configuration;+using AccessSchedule = Jellyfin.Data.Entities.AccessSchedule;namespace MediaBrowser.Model.Users{