Prepared Seperation of Database components for future multi provider support

pull/13451/head
JPVenson 3 months ago
parent b318f33599
commit aa811eb1e3

@ -24,5 +24,19 @@
"hostRequirements": {
"memory": "8gb",
"cpus": 4
}, "remoteEnv": {
"JELLYFIN_DATA_DIR": "/config"
},
"mounts": [
"source=/opt/docker/data/jellyfin/testConfig/,target=/config,type=bind,consistency=cached",
"source=/opt/docker/data/jellyfin/config10.9.11/metadata,target=/config/metadata,type=bind,consistency=cached",
"source=/mnt/video,target=/media,type=bind,consistency=cached"
],
"customizations": {
"vscode": {
"extensions": [
"alexcvzz.vscode-sqlite"
]
}
}
}

@ -31,6 +31,7 @@
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.1" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.Caching.Abstractions" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="9.0.1" />

@ -18,6 +18,7 @@
<ProjectReference Include="..\Emby.Photos\Emby.Photos.csproj" />
<ProjectReference Include="..\src\Jellyfin.Drawing\Jellyfin.Drawing.csproj" />
<ProjectReference Include="..\MediaBrowser.MediaEncoding\MediaBrowser.MediaEncoding.csproj" />
<ProjectReference Include="..\Jellyfin.Database\Jellyfin.Database.Implementations\Jellyfin.Database.Implementations.csproj" />
</ItemGroup>
<ItemGroup>

@ -1,6 +1,7 @@
#pragma warning disable CS1591
using System.Threading.Tasks;
using Jellyfin.Data;
using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Net;
using Microsoft.AspNetCore.Http;

@ -18,6 +18,7 @@ using Emby.Server.Implementations.Library.Validators;
using Emby.Server.Implementations.Playlists;
using Emby.Server.Implementations.ScheduledTasks.Tasks;
using Emby.Server.Implementations.Sorting;
using Jellyfin.Data;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;

@ -13,6 +13,7 @@ using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using AsyncKeyedLock;
using Jellyfin.Data;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;

@ -6,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Jellyfin.Data;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;

@ -18,6 +18,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
private readonly ILogger<OptimizeDatabaseTask> _logger;
private readonly ILocalizationManager _localization;
private readonly IDbContextFactory<JellyfinDbContext> _provider;
private readonly IJellyfinDatabaseProvider _jellyfinDatabaseProvider;
/// <summary>
/// Initializes a new instance of the <see cref="OptimizeDatabaseTask" /> class.
@ -25,14 +26,17 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
/// <param name="logger">Instance of the <see cref="ILogger"/> interface.</param>
/// <param name="localization">Instance of the <see cref="ILocalizationManager"/> interface.</param>
/// <param name="provider">Instance of the <see cref="IDbContextFactory{JellyfinDbContext}"/> interface.</param>
/// <param name="jellyfinDatabaseProvider">Instance of the JellyfinDatabaseProvider that can be used for provider specific operations.</param>
public OptimizeDatabaseTask(
ILogger<OptimizeDatabaseTask> logger,
ILocalizationManager localization,
IDbContextFactory<JellyfinDbContext> provider)
IDbContextFactory<JellyfinDbContext> provider,
IJellyfinDatabaseProvider jellyfinDatabaseProvider)
{
_logger = logger;
_localization = localization;
_provider = provider;
_jellyfinDatabaseProvider = jellyfinDatabaseProvider;
}
/// <inheritdoc />
@ -73,20 +77,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
try
{
var context = await _provider.CreateDbContextAsync(cancellationToken).ConfigureAwait(false);
await using (context.ConfigureAwait(false))
{
if (context.Database.IsSqlite())
{
await context.Database.ExecuteSqlRawAsync("PRAGMA optimize", cancellationToken).ConfigureAwait(false);
await context.Database.ExecuteSqlRawAsync("VACUUM", cancellationToken).ConfigureAwait(false);
_logger.LogInformation("jellyfin.db optimized successfully!");
}
else
{
_logger.LogInformation("This database doesn't support optimization");
}
}
await _jellyfinDatabaseProvider.RunScheduledOptimisation(cancellationToken).ConfigureAwait(false);
}
catch (Exception e)
{

@ -7,6 +7,7 @@ using System.Globalization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Data;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Entities.Security;
using Jellyfin.Data.Enums;

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Jellyfin.Data;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;

@ -3,6 +3,7 @@ using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using Jellyfin.Api.Constants;
using Jellyfin.Data;
using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Authentication;
using MediaBrowser.Controller.Net;

@ -1,6 +1,7 @@
using System.Threading.Tasks;
using Jellyfin.Api.Constants;
using Jellyfin.Api.Extensions;
using Jellyfin.Data;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Extensions;

@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Jellyfin.Api.Extensions;
using Jellyfin.Data;
using Jellyfin.Extensions;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Library;

@ -4,6 +4,7 @@ using System.Linq;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.ModelBinders;
using Jellyfin.Data;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Extensions;

@ -7,6 +7,7 @@ using Jellyfin.Api.Constants;
using Jellyfin.Api.Extensions;
using Jellyfin.Api.Helpers;
using Jellyfin.Api.Models.UserDtos;
using Jellyfin.Data;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Common.Api;

@ -7,6 +7,7 @@ using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Jellyfin.Api.Extensions;
using Jellyfin.Data;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;

@ -1,5 +1,6 @@
using System;
using System.Threading.Tasks;
using Jellyfin.Data;
using Jellyfin.Data.Enums;
using Jellyfin.Data.Events;
using MediaBrowser.Controller.Authentication;

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Jellyfin.Data;
using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Authentication;
using MediaBrowser.Controller.Library;

@ -1,31 +0,0 @@
using System.Collections.Generic;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
namespace Jellyfin.Data.Interfaces
{
/// <summary>
/// An abstraction representing an entity that has permissions.
/// </summary>
public interface IHasPermissions
{
/// <summary>
/// Gets a collection containing this entity's permissions.
/// </summary>
ICollection<Permission> Permissions { get; }
/// <summary>
/// Checks whether this entity has the specified permission kind.
/// </summary>
/// <param name="kind">The kind of permission.</param>
/// <returns><c>true</c> if this entity has the specified permission, <c>false</c> otherwise.</returns>
bool HasPermission(PermissionKind kind);
/// <summary>
/// Sets the specified permission to the provided value.
/// </summary>
/// <param name="kind">The kind of permission.</param>
/// <param name="value">The value to set.</param>
void SetPermission(PermissionKind kind, bool value);
}
}

@ -38,6 +38,10 @@
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Jellyfin.Database\Jellyfin.Database.Implementations\Jellyfin.Database.Implementations.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" />
</ItemGroup>

@ -0,0 +1,220 @@
using System;
using System.ComponentModel;
using System.Linq;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
using Jellyfin.Data.Interfaces;
namespace Jellyfin.Data;
/// <summary>
/// Contains extension methods for manipulation of <see cref="User"/> entities.
/// </summary>
public static class UserEntityExtensions
{
/// <summary>
/// The values being delimited here are Guids, so commas work as they do not appear in Guids.
/// </summary>
private const char Delimiter = ',';
/// <summary>
/// Checks whether the user has the specified permission.
/// </summary>
/// <param name="entity">The entity to update.</param>
/// <param name="kind">The permission kind.</param>
/// <returns><c>True</c> if the user has the specified permission.</returns>
public static bool HasPermission(this IHasPermissions entity, PermissionKind kind)
{
return entity.Permissions.FirstOrDefault(p => p.Kind == kind)?.Value ?? false;
}
/// <summary>
/// Sets the given permission kind to the provided value.
/// </summary>
/// <param name="entity">The entity to update.</param>
/// <param name="kind">The permission kind.</param>
/// <param name="value">The value to set.</param>
public static void SetPermission(this IHasPermissions entity, PermissionKind kind, bool value)
{
var currentPermission = entity.Permissions.FirstOrDefault(p => p.Kind == kind);
if (currentPermission is null)
{
entity.Permissions.Add(new Permission(kind, value));
}
else
{
currentPermission.Value = value;
}
}
/// <summary>
/// Gets the user's preferences for the given preference kind.
/// </summary>
/// <param name="entity">The entity to update.</param>
/// <param name="preference">The preference kind.</param>
/// <returns>A string array containing the user's preferences.</returns>
public static string[] GetPreference(this User entity, PreferenceKind preference)
{
var val = entity.Preferences.FirstOrDefault(p => p.Kind == preference)?.Value;
return string.IsNullOrEmpty(val) ? Array.Empty<string>() : val.Split(Delimiter);
}
/// <summary>
/// Gets the user's preferences for the given preference kind.
/// </summary>
/// <param name="entity">The entity to update.</param>
/// <param name="preference">The preference kind.</param>
/// <typeparam name="T">Type of preference.</typeparam>
/// <returns>A {T} array containing the user's preference.</returns>
public static T[] GetPreferenceValues<T>(this User entity, PreferenceKind preference)
{
var val = entity.Preferences.FirstOrDefault(p => p.Kind == preference)?.Value;
if (string.IsNullOrEmpty(val))
{
return Array.Empty<T>();
}
// Convert array of {string} to array of {T}
var converter = TypeDescriptor.GetConverter(typeof(T));
var stringValues = val.Split(Delimiter);
var convertedCount = 0;
var parsedValues = new T[stringValues.Length];
for (var i = 0; i < stringValues.Length; i++)
{
try
{
var parsedValue = converter.ConvertFromString(stringValues[i].Trim());
if (parsedValue is not null)
{
parsedValues[convertedCount++] = (T)parsedValue;
}
}
catch (FormatException)
{
// Unable to convert value
}
}
return parsedValues[..convertedCount];
}
/// <summary>
/// Sets the specified preference to the given value.
/// </summary>
/// <param name="entity">The entity to update.</param>
/// <param name="preference">The preference kind.</param>
/// <param name="values">The values.</param>
public static void SetPreference(this User entity, PreferenceKind preference, string[] values)
{
var value = string.Join(Delimiter, values);
var currentPreference = entity.Preferences.FirstOrDefault(p => p.Kind == preference);
if (currentPreference is null)
{
entity.Preferences.Add(new Preference(preference, value));
}
else
{
currentPreference.Value = value;
}
}
/// <summary>
/// Sets the specified preference to the given value.
/// </summary>
/// <param name="entity">The entity to update.</param>
/// <param name="preference">The preference kind.</param>
/// <param name="values">The values.</param>
/// <typeparam name="T">The type of value.</typeparam>
public static void SetPreference<T>(this User entity, PreferenceKind preference, T[] values)
{
var value = string.Join(Delimiter, values);
var currentPreference = entity.Preferences.FirstOrDefault(p => p.Kind == preference);
if (currentPreference is null)
{
entity.Preferences.Add(new Preference(preference, value));
}
else
{
currentPreference.Value = value;
}
}
/// <summary>
/// Checks whether this user is currently allowed to use the server.
/// </summary>
/// <param name="entity">The entity to update.</param>
/// <returns><c>True</c> if the current time is within an access schedule, or there are no access schedules.</returns>
public static bool IsParentalScheduleAllowed(this User entity)
{
return entity.AccessSchedules.Count == 0
|| entity.AccessSchedules.Any(i => IsParentalScheduleAllowed(i, DateTime.UtcNow));
}
/// <summary>
/// Checks whether the provided folder is in this user's grouped folders.
/// </summary>
/// <param name="entity">The entity to update.</param>
/// <param name="id">The Guid of the folder.</param>
/// <returns><c>True</c> if the folder is in the user's grouped folders.</returns>
public static bool IsFolderGrouped(this User entity, Guid id)
{
return Array.IndexOf(GetPreferenceValues<Guid>(entity, PreferenceKind.GroupedFolders), id) != -1;
}
/// <summary>
/// Initializes the default permissions for a user. Should only be called on user creation.
/// </summary>
/// <param name="entity">The entity to update.</param>
// TODO: make these user configurable?
public static void AddDefaultPermissions(this User entity)
{
entity.Permissions.Add(new Permission(PermissionKind.IsAdministrator, false));
entity.Permissions.Add(new Permission(PermissionKind.IsDisabled, false));
entity.Permissions.Add(new Permission(PermissionKind.IsHidden, true));
entity.Permissions.Add(new Permission(PermissionKind.EnableAllChannels, true));
entity.Permissions.Add(new Permission(PermissionKind.EnableAllDevices, true));
entity.Permissions.Add(new Permission(PermissionKind.EnableAllFolders, true));
entity.Permissions.Add(new Permission(PermissionKind.EnableContentDeletion, false));
entity.Permissions.Add(new Permission(PermissionKind.EnableContentDownloading, true));
entity.Permissions.Add(new Permission(PermissionKind.EnableMediaConversion, true));
entity.Permissions.Add(new Permission(PermissionKind.EnableMediaPlayback, true));
entity.Permissions.Add(new Permission(PermissionKind.EnablePlaybackRemuxing, true));
entity.Permissions.Add(new Permission(PermissionKind.EnablePublicSharing, true));
entity.Permissions.Add(new Permission(PermissionKind.EnableRemoteAccess, true));
entity.Permissions.Add(new Permission(PermissionKind.EnableSyncTranscoding, true));
entity.Permissions.Add(new Permission(PermissionKind.EnableAudioPlaybackTranscoding, true));
entity.Permissions.Add(new Permission(PermissionKind.EnableLiveTvAccess, true));
entity.Permissions.Add(new Permission(PermissionKind.EnableLiveTvManagement, true));
entity.Permissions.Add(new Permission(PermissionKind.EnableSharedDeviceControl, true));
entity.Permissions.Add(new Permission(PermissionKind.EnableVideoPlaybackTranscoding, true));
entity.Permissions.Add(new Permission(PermissionKind.ForceRemoteSourceTranscoding, false));
entity.Permissions.Add(new Permission(PermissionKind.EnableRemoteControlOfOtherUsers, false));
entity.Permissions.Add(new Permission(PermissionKind.EnableCollectionManagement, false));
entity.Permissions.Add(new Permission(PermissionKind.EnableSubtitleManagement, false));
entity.Permissions.Add(new Permission(PermissionKind.EnableLyricManagement, false));
}
/// <summary>
/// Initializes the default preferences. Should only be called on user creation.
/// </summary>
/// <param name="entity">The entity to update.</param>
public static void AddDefaultPreferences(this User entity)
{
foreach (var val in Enum.GetValues<PreferenceKind>())
{
entity.Preferences.Add(new Preference(val, string.Empty));
}
}
private static bool IsParentalScheduleAllowed(AccessSchedule schedule, DateTime date)
{
var localTime = date.ToLocalTime();
var hour = localTime.TimeOfDay.TotalHours;
var currentDayOfWeek = localTime.DayOfWeek;
return schedule.DayOfWeek.Contains(currentDayOfWeek)
&& hour >= schedule.StartHour
&& hour <= schedule.EndHour;
}
}

@ -59,18 +59,6 @@ namespace Jellyfin.Data.Entities
/// </summary>
public virtual ICollection<Preference> Preferences { get; private set; }
/// <inheritdoc/>
public bool HasPermission(PermissionKind kind)
{
return Permissions.First(p => p.Kind == kind).Value;
}
/// <inheritdoc/>
public void SetPermission(PermissionKind kind, bool value)
{
Permissions.First(p => p.Kind == kind).Value = value;
}
/// <inheritdoc />
public void OnSavingChanges()
{

@ -15,11 +15,6 @@ namespace Jellyfin.Data.Entities
/// </summary>
public class User : IHasPermissions, IHasConcurrencyToken
{
/// <summary>
/// The values being delimited here are Guids, so commas work as they do not appear in Guids.
/// </summary>
private const char Delimiter = ',';
/// <summary>
/// Initializes a new instance of the <see cref="User"/> class.
/// Public constructor with required data.
@ -339,196 +334,5 @@ namespace Jellyfin.Data.Entities
{
RowVersion++;
}
/// <summary>
/// Checks whether the user has the specified permission.
/// </summary>
/// <param name="kind">The permission kind.</param>
/// <returns><c>True</c> if the user has the specified permission.</returns>
public bool HasPermission(PermissionKind kind)
{
return Permissions.FirstOrDefault(p => p.Kind == kind)?.Value ?? false;
}
/// <summary>
/// Sets the given permission kind to the provided value.
/// </summary>
/// <param name="kind">The permission kind.</param>
/// <param name="value">The value to set.</param>
public void SetPermission(PermissionKind kind, bool value)
{
var currentPermission = Permissions.FirstOrDefault(p => p.Kind == kind);
if (currentPermission is null)
{
Permissions.Add(new Permission(kind, value));
}
else
{
currentPermission.Value = value;
}
}
/// <summary>
/// Gets the user's preferences for the given preference kind.
/// </summary>
/// <param name="preference">The preference kind.</param>
/// <returns>A string array containing the user's preferences.</returns>
public string[] GetPreference(PreferenceKind preference)
{
var val = Preferences.FirstOrDefault(p => p.Kind == preference)?.Value;
return string.IsNullOrEmpty(val) ? Array.Empty<string>() : val.Split(Delimiter);
}
/// <summary>
/// Gets the user's preferences for the given preference kind.
/// </summary>
/// <param name="preference">The preference kind.</param>
/// <typeparam name="T">Type of preference.</typeparam>
/// <returns>A {T} array containing the user's preference.</returns>
public T[] GetPreferenceValues<T>(PreferenceKind preference)
{
var val = Preferences.FirstOrDefault(p => p.Kind == preference)?.Value;
if (string.IsNullOrEmpty(val))
{
return Array.Empty<T>();
}
// Convert array of {string} to array of {T}
var converter = TypeDescriptor.GetConverter(typeof(T));
var stringValues = val.Split(Delimiter);
var convertedCount = 0;
var parsedValues = new T[stringValues.Length];
for (var i = 0; i < stringValues.Length; i++)
{
try
{
var parsedValue = converter.ConvertFromString(stringValues[i].Trim());
if (parsedValue is not null)
{
parsedValues[convertedCount++] = (T)parsedValue;
}
}
catch (FormatException)
{
// Unable to convert value
}
}
return parsedValues[..convertedCount];
}
/// <summary>
/// Sets the specified preference to the given value.
/// </summary>
/// <param name="preference">The preference kind.</param>
/// <param name="values">The values.</param>
public void SetPreference(PreferenceKind preference, string[] values)
{
var value = string.Join(Delimiter, values);
var currentPreference = Preferences.FirstOrDefault(p => p.Kind == preference);
if (currentPreference is null)
{
Preferences.Add(new Preference(preference, value));
}
else
{
currentPreference.Value = value;
}
}
/// <summary>
/// Sets the specified preference to the given value.
/// </summary>
/// <param name="preference">The preference kind.</param>
/// <param name="values">The values.</param>
/// <typeparam name="T">The type of value.</typeparam>
public void SetPreference<T>(PreferenceKind preference, T[] values)
{
var value = string.Join(Delimiter, values);
var currentPreference = Preferences.FirstOrDefault(p => p.Kind == preference);
if (currentPreference is null)
{
Preferences.Add(new Preference(preference, value));
}
else
{
currentPreference.Value = value;
}
}
/// <summary>
/// Checks whether this user is currently allowed to use the server.
/// </summary>
/// <returns><c>True</c> if the current time is within an access schedule, or there are no access schedules.</returns>
public bool IsParentalScheduleAllowed()
{
return AccessSchedules.Count == 0
|| AccessSchedules.Any(i => IsParentalScheduleAllowed(i, DateTime.UtcNow));
}
/// <summary>
/// Checks whether the provided folder is in this user's grouped folders.
/// </summary>
/// <param name="id">The Guid of the folder.</param>
/// <returns><c>True</c> if the folder is in the user's grouped folders.</returns>
public bool IsFolderGrouped(Guid id)
{
return Array.IndexOf(GetPreferenceValues<Guid>(PreferenceKind.GroupedFolders), id) != -1;
}
/// <summary>
/// Initializes the default permissions for a user. Should only be called on user creation.
/// </summary>
// TODO: make these user configurable?
public void AddDefaultPermissions()
{
Permissions.Add(new Permission(PermissionKind.IsAdministrator, false));
Permissions.Add(new Permission(PermissionKind.IsDisabled, false));
Permissions.Add(new Permission(PermissionKind.IsHidden, true));
Permissions.Add(new Permission(PermissionKind.EnableAllChannels, true));
Permissions.Add(new Permission(PermissionKind.EnableAllDevices, true));
Permissions.Add(new Permission(PermissionKind.EnableAllFolders, true));
Permissions.Add(new Permission(PermissionKind.EnableContentDeletion, false));
Permissions.Add(new Permission(PermissionKind.EnableContentDownloading, true));
Permissions.Add(new Permission(PermissionKind.EnableMediaConversion, true));
Permissions.Add(new Permission(PermissionKind.EnableMediaPlayback, true));
Permissions.Add(new Permission(PermissionKind.EnablePlaybackRemuxing, true));
Permissions.Add(new Permission(PermissionKind.EnablePublicSharing, true));
Permissions.Add(new Permission(PermissionKind.EnableRemoteAccess, true));
Permissions.Add(new Permission(PermissionKind.EnableSyncTranscoding, true));
Permissions.Add(new Permission(PermissionKind.EnableAudioPlaybackTranscoding, true));
Permissions.Add(new Permission(PermissionKind.EnableLiveTvAccess, true));
Permissions.Add(new Permission(PermissionKind.EnableLiveTvManagement, true));
Permissions.Add(new Permission(PermissionKind.EnableSharedDeviceControl, true));
Permissions.Add(new Permission(PermissionKind.EnableVideoPlaybackTranscoding, true));
Permissions.Add(new Permission(PermissionKind.ForceRemoteSourceTranscoding, false));
Permissions.Add(new Permission(PermissionKind.EnableRemoteControlOfOtherUsers, false));
Permissions.Add(new Permission(PermissionKind.EnableCollectionManagement, false));
Permissions.Add(new Permission(PermissionKind.EnableSubtitleManagement, false));
Permissions.Add(new Permission(PermissionKind.EnableLyricManagement, false));
}
/// <summary>
/// Initializes the default preferences. Should only be called on user creation.
/// </summary>
public void AddDefaultPreferences()
{
foreach (var val in Enum.GetValues<PreferenceKind>())
{
Preferences.Add(new Preference(val, string.Empty));
}
}
private static bool IsParentalScheduleAllowed(AccessSchedule schedule, DateTime date)
{
var localTime = date.ToLocalTime();
var hour = localTime.TimeOfDay.TotalHours;
var currentDayOfWeek = localTime.DayOfWeek;
return schedule.DayOfWeek.Contains(currentDayOfWeek)
&& hour >= schedule.StartHour
&& hour <= schedule.EndHour;
}
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save