Updated code to correct build errors for Jelyfin.Data and Jellyfin.Database.Implementations
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
// Copyright (c) PlaceholderCompany. All rights reserved.
|
||||
// </copyright>
|
||||
|
||||
namespace Jellyfin.Data;
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
@@ -9,8 +11,6 @@ using Jellyfin.Database.Implementations.Entities;
|
||||
using Jellyfin.Database.Implementations.Enums;
|
||||
using Jellyfin.Database.Implementations.Interfaces;
|
||||
|
||||
namespace Jellyfin.Data;
|
||||
|
||||
/// <summary>
|
||||
/// Contains extension methods for manipulation of <see cref="User"/> entities.
|
||||
/// </summary>
|
||||
@@ -29,6 +29,7 @@ public static class UserEntityExtensions
|
||||
/// <returns><c>True</c> if the user has the specified permission.</returns>
|
||||
public static bool HasPermission(this IHasPermissions entity, PermissionKind kind)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(entity);
|
||||
return entity.Permissions.FirstOrDefault(p => p.Kind == kind)?.Value ?? false;
|
||||
}
|
||||
|
||||
@@ -40,6 +41,7 @@ public static class UserEntityExtensions
|
||||
/// <param name="value">The value to set.</param>
|
||||
public static void SetPermission(this IHasPermissions entity, PermissionKind kind, bool value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(entity);
|
||||
var currentPermission = entity.Permissions.FirstOrDefault(p => p.Kind == kind);
|
||||
if (currentPermission is null)
|
||||
{
|
||||
@@ -59,6 +61,7 @@ public static class UserEntityExtensions
|
||||
/// <returns>A string array containing the user's preferences.</returns>
|
||||
public static string[] GetPreference(this User entity, PreferenceKind preference)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(entity);
|
||||
var val = entity.Preferences.FirstOrDefault(p => p.Kind == preference)?.Value;
|
||||
|
||||
return string.IsNullOrEmpty(val) ? Array.Empty<string>() : val.Split(Delimiter);
|
||||
@@ -73,6 +76,7 @@ public static class UserEntityExtensions
|
||||
/// <returns>A {T} array containing the user's preference.</returns>
|
||||
public static T[] GetPreferenceValues<T>(this User entity, PreferenceKind preference)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(entity);
|
||||
var val = entity.Preferences.FirstOrDefault(p => p.Kind == preference)?.Value;
|
||||
if (string.IsNullOrEmpty(val))
|
||||
{
|
||||
@@ -111,6 +115,7 @@ public static class UserEntityExtensions
|
||||
/// <param name="values">The values.</param>
|
||||
public static void SetPreference(this User entity, PreferenceKind preference, string[] values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(entity);
|
||||
var value = string.Join(Delimiter, values);
|
||||
var currentPreference = entity.Preferences.FirstOrDefault(p => p.Kind == preference);
|
||||
if (currentPreference is null)
|
||||
@@ -132,6 +137,7 @@ public static class UserEntityExtensions
|
||||
/// <typeparam name="T">The type of value.</typeparam>
|
||||
public static void SetPreference<T>(this User entity, PreferenceKind preference, T[] values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(entity);
|
||||
var value = string.Join(Delimiter, values);
|
||||
var currentPreference = entity.Preferences.FirstOrDefault(p => p.Kind == preference);
|
||||
if (currentPreference is null)
|
||||
@@ -151,6 +157,7 @@ public static class UserEntityExtensions
|
||||
/// <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)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(entity);
|
||||
return entity.AccessSchedules.Count == 0
|
||||
|| entity.AccessSchedules.Any(i => IsParentalScheduleAllowed(i, DateTime.UtcNow));
|
||||
}
|
||||
@@ -173,6 +180,7 @@ public static class UserEntityExtensions
|
||||
// TODO: make these user configurable?
|
||||
public static void AddDefaultPermissions(this User entity)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(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));
|
||||
@@ -207,6 +215,7 @@ public static class UserEntityExtensions
|
||||
{
|
||||
foreach (var val in Enum.GetValues<PreferenceKind>())
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(entity);
|
||||
entity.Preferences.Add(new Preference(val, string.Empty));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user