Switch to file scopped namespaces

This commit is contained in:
Zoe Roux 2024-03-23 00:14:34 +01:00
parent 35e37bbe76
commit 18e301f26a
No known key found for this signature in database
99 changed files with 8936 additions and 9141 deletions

View File

@ -16,6 +16,8 @@ dotnet_diagnostic.IDE0055.severity = none
dotnet_diagnostic.IDE0058.severity = none
dotnet_diagnostic.IDE0130.severity = none
# Convert to file-scoped namespace
csharp_style_namespace_declarations = file_scoped:warning
# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true
csharp_using_directive_placement = outside_namespace:warning

View File

@ -18,8 +18,8 @@
using Kyoo.Abstractions.Models;
namespace Kyoo.Abstractions.Controllers
{
namespace Kyoo.Abstractions.Controllers;
/// <summary>
/// An interface to interact with the database. Every repository is mapped through here.
/// </summary>
@ -78,4 +78,3 @@ namespace Kyoo.Abstractions.Controllers
/// </summary>
IRepository<User> Users { get; }
}
}

View File

@ -19,8 +19,8 @@
using Kyoo.Abstractions.Models.Permissions;
using Microsoft.AspNetCore.Mvc.Filters;
namespace Kyoo.Abstractions.Controllers
{
namespace Kyoo.Abstractions.Controllers;
/// <summary>
/// A service to validate permissions.
/// </summary>
@ -44,4 +44,3 @@ namespace Kyoo.Abstractions.Controllers
/// <returns>An authorization filter used to validate the permission.</returns>
IFilterMetadata Create(PartialPermissionAttribute attribute);
}
}

View File

@ -21,8 +21,8 @@ using System.Collections.Generic;
using Autofac;
using Microsoft.Extensions.DependencyInjection;
namespace Kyoo.Abstractions.Controllers
{
namespace Kyoo.Abstractions.Controllers;
/// <summary>
/// A common interface used to discord plugins
/// </summary>
@ -63,4 +63,3 @@ namespace Kyoo.Abstractions.Controllers
// Skipped
}
}
}

View File

@ -20,8 +20,8 @@ using System;
using System.Collections.Generic;
using Kyoo.Abstractions.Models.Exceptions;
namespace Kyoo.Abstractions.Controllers
{
namespace Kyoo.Abstractions.Controllers;
/// <summary>
/// A manager to load plugins and retrieve information from them.
/// </summary>
@ -67,4 +67,3 @@ namespace Kyoo.Abstractions.Controllers
/// </param>
public void LoadPlugins(params Type[] plugins);
}
}

View File

@ -23,8 +23,8 @@ using Kyoo.Abstractions.Models;
using Kyoo.Abstractions.Models.Exceptions;
using Kyoo.Abstractions.Models.Utils;
namespace Kyoo.Abstractions.Controllers
{
namespace Kyoo.Abstractions.Controllers;
/// <summary>
/// A common repository for every resources.
/// </summary>
@ -170,8 +170,7 @@ namespace Kyoo.Abstractions.Controllers
/// </summary>
/// <param name="obj">The resource newly created.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
protected static Task OnResourceCreated(T obj) =>
OnCreated?.Invoke(obj) ?? Task.CompletedTask;
protected static Task OnResourceCreated(T obj) => OnCreated?.Invoke(obj) ?? Task.CompletedTask;
/// <summary>
/// Edit a resource and replace every property
@ -203,8 +202,7 @@ namespace Kyoo.Abstractions.Controllers
/// </summary>
/// <param name="obj">The resource newly edited.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
protected static Task OnResourceEdited(T obj) =>
OnEdited?.Invoke(obj) ?? Task.CompletedTask;
protected static Task OnResourceEdited(T obj) => OnEdited?.Invoke(obj) ?? Task.CompletedTask;
/// <summary>
/// Delete a resource by it's ID
@ -247,8 +245,7 @@ namespace Kyoo.Abstractions.Controllers
/// </summary>
/// <param name="obj">The resource newly deleted.</param>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
protected static Task OnResourceDeleted(T obj) =>
OnDeleted?.Invoke(obj) ?? Task.CompletedTask;
protected static Task OnResourceDeleted(T obj) => OnDeleted?.Invoke(obj) ?? Task.CompletedTask;
}
/// <summary>
@ -268,4 +265,3 @@ namespace Kyoo.Abstractions.Controllers
Task<User> AddExternalToken(Guid userId, string provider, ExternalToken token);
Task<User> DeleteExternalToken(Guid userId, string provider);
}
}

View File

@ -21,8 +21,8 @@ using System.IO;
using System.Threading.Tasks;
using Kyoo.Abstractions.Models;
namespace Kyoo.Abstractions.Controllers
{
namespace Kyoo.Abstractions.Controllers;
/// <summary>
/// Download images and retrieve the path of those images for a resource.
/// </summary>
@ -76,4 +76,3 @@ namespace Kyoo.Abstractions.Controllers
/// <param name="image">The byte stream of the image. Null to delete the image.</param>
Task SetUserImage(Guid userId, Stream? image);
}
}

View File

@ -19,8 +19,8 @@
using System;
using Microsoft.Extensions.DependencyInjection;
namespace Kyoo.Abstractions.Controllers
{
namespace Kyoo.Abstractions.Controllers;
/// <summary>
/// A list of constant priorities used for <see cref="IStartupAction"/>'s <see cref="IStartupAction.Priority"/>.
/// It also contains helper methods for creating new <see cref="StartupAction"/>.
@ -102,10 +102,7 @@ namespace Kyoo.Abstractions.Controllers
/// <typeparam name="T2">A second dependency that this action will use.</typeparam>
/// <typeparam name="T3">A third dependency that this action will use.</typeparam>
/// <returns>A new <see cref="StartupAction"/></returns>
public static StartupAction<T, T2, T3> New<T, T2, T3>(
Action<T, T2, T3> action,
int priority
)
public static StartupAction<T, T2, T3> New<T, T2, T3>(Action<T, T2, T3> action, int priority)
where T : notnull
where T2 : notnull
where T3 : notnull => new(action, priority);
@ -271,4 +268,3 @@ namespace Kyoo.Abstractions.Controllers
/// <param name="provider">The service provider containing all services can be used.</param>
void Run(IServiceProvider provider);
}
}

View File

@ -23,8 +23,8 @@ using System.Security.Claims;
using Kyoo.Abstractions.Models.Exceptions;
using Kyoo.Authentication.Models;
namespace Kyoo.Authentication
{
namespace Kyoo.Authentication;
/// <summary>
/// Extension methods.
/// </summary>
@ -62,4 +62,3 @@ namespace Kyoo.Authentication
return ret.Value;
}
}
}

View File

@ -18,8 +18,8 @@
using System;
namespace Kyoo.Abstractions.Models.Attributes
{
namespace Kyoo.Abstractions.Models.Attributes;
/// <summary>
/// An attribute to specify on apis to specify it's documentation's name and category.
/// If this is applied on a method, the specified method will be exploded from the controller's page and be
@ -49,4 +49,3 @@ namespace Kyoo.Abstractions.Models.Attributes
Name = name;
}
}
}

View File

@ -18,11 +18,10 @@
using System;
namespace Kyoo.Abstractions.Models.Attributes
{
namespace Kyoo.Abstractions.Models.Attributes;
/// <summary>
/// An attribute to inform that the property is computed automatically and can't be assigned manually.
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class ComputedAttribute : NotMergeableAttribute { }
}

View File

@ -18,8 +18,8 @@
using System;
namespace Kyoo.Abstractions.Models.Attributes
{
namespace Kyoo.Abstractions.Models.Attributes;
/// <summary>
/// The targeted relation can be loaded.
/// </summary>
@ -51,4 +51,3 @@ namespace Kyoo.Abstractions.Models.Attributes
RelationID = relationID;
}
}
}

View File

@ -18,8 +18,8 @@
using System;
namespace Kyoo.Abstractions.Models.Attributes
{
namespace Kyoo.Abstractions.Models.Attributes;
/// <summary>
/// Specify that a property can't be merged.
/// </summary>
@ -37,4 +37,3 @@ namespace Kyoo.Abstractions.Models.Attributes
/// <param name="merged">The object that has been merged with this.</param>
void OnMerge(object merged);
}
}

View File

@ -21,8 +21,8 @@ using Kyoo.Abstractions.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection;
namespace Kyoo.Abstractions.Models.Permissions
{
namespace Kyoo.Abstractions.Models.Permissions;
/// <summary>
/// Specify one part of a permissions needed for the API (the kind or the type).
/// </summary>
@ -85,4 +85,3 @@ namespace Kyoo.Abstractions.Models.Permissions
/// <inheritdoc />
public bool IsReusable => true;
}
}

View File

@ -21,8 +21,8 @@ using Kyoo.Abstractions.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection;
namespace Kyoo.Abstractions.Models.Permissions
{
namespace Kyoo.Abstractions.Models.Permissions;
/// <summary>
/// The kind of permission needed.
/// </summary>
@ -134,4 +134,3 @@ namespace Kyoo.Abstractions.Models.Permissions
return Type;
}
}
}

View File

@ -18,8 +18,8 @@
using System;
namespace Kyoo.Abstractions.Models.Permissions
{
namespace Kyoo.Abstractions.Models.Permissions;
/// <summary>
/// The annotated route can only be accessed by a logged in user.
/// </summary>
@ -28,4 +28,3 @@ namespace Kyoo.Abstractions.Models.Permissions
{
// TODO: Implement a Filter Attribute to make this work. For now, this attribute is only useful as documentation.
}
}

View File

@ -19,8 +19,8 @@
using System;
using System.Runtime.Serialization;
namespace Kyoo.Abstractions.Models.Exceptions
{
namespace Kyoo.Abstractions.Models.Exceptions;
/// <summary>
/// An exception raised when an item already exists in the database.
/// </summary>
@ -50,4 +50,3 @@ namespace Kyoo.Abstractions.Models.Exceptions
protected DuplicatedItemException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
}

View File

@ -19,8 +19,8 @@
using System;
using System.Runtime.Serialization;
namespace Kyoo.Abstractions.Models.Exceptions
{
namespace Kyoo.Abstractions.Models.Exceptions;
/// <summary>
/// An exception raised when an item could not be found.
/// </summary>
@ -48,4 +48,3 @@ namespace Kyoo.Abstractions.Models.Exceptions
protected ItemNotFoundException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
}

View File

@ -19,8 +19,8 @@
using System;
using System.Runtime.Serialization;
namespace Kyoo.Abstractions.Models.Exceptions
{
namespace Kyoo.Abstractions.Models.Exceptions;
[Serializable]
public class UnauthorizedException : Exception
{
@ -33,4 +33,3 @@ namespace Kyoo.Abstractions.Models.Exceptions
protected UnauthorizedException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
}

View File

@ -16,8 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
namespace Kyoo.Abstractions.Models
{
namespace Kyoo.Abstractions.Models;
/// <summary>
/// A genre that allow one to specify categories for shows.
/// </summary>
@ -42,4 +42,3 @@ namespace Kyoo.Abstractions.Models
War,
Western,
}
}

View File

@ -16,8 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
namespace Kyoo.Abstractions.Models
{
namespace Kyoo.Abstractions.Models;
/// <summary>
/// ID and link of an item on an external provider.
/// </summary>
@ -33,4 +33,3 @@ namespace Kyoo.Abstractions.Models
/// </summary>
public string? Link { get; set; }
}
}

View File

@ -20,8 +20,8 @@ using System.Collections.Generic;
using System.Linq;
using Kyoo.Utils;
namespace Kyoo.Abstractions.Models
{
namespace Kyoo.Abstractions.Models;
/// <summary>
/// A page of resource that contains information about the pagination of resources.
/// </summary>
@ -67,13 +67,7 @@ namespace Kyoo.Abstractions.Models
/// <param name="previous">The link of the previous page.</param>
/// <param name="next">The link of the next page.</param>
/// <param name="first">The link of the first page.</param>
public Page(
ICollection<T> items,
string @this,
string? previous,
string? next,
string first
)
public Page(ICollection<T> items, string @this, string? previous, string? next, string first)
{
Items = items;
This = @this;
@ -109,4 +103,3 @@ namespace Kyoo.Abstractions.Models
First = url + query.ToQueryString();
}
}
}

View File

@ -23,8 +23,8 @@ using System.Text.Json.Serialization;
using Kyoo.Abstractions.Controllers;
using Kyoo.Utils;
namespace Kyoo.Abstractions.Models
{
namespace Kyoo.Abstractions.Models;
/// <summary>
/// A class representing collections of <see cref="Show"/>.
/// </summary>
@ -88,4 +88,3 @@ namespace Kyoo.Abstractions.Models
}
}
}
}

View File

@ -26,8 +26,8 @@ using EntityFrameworkCore.Projectables;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models.Attributes;
namespace Kyoo.Abstractions.Models
{
namespace Kyoo.Abstractions.Models;
/// <summary>
/// A class to represent a single show's episode.
/// </summary>
@ -52,12 +52,7 @@ namespace Kyoo.Abstractions.Models
get
{
if (ShowSlug != null || Show?.Slug != null)
return GetSlug(
ShowSlug ?? Show!.Slug,
SeasonNumber,
EpisodeNumber,
AbsoluteNumber
);
return GetSlug(ShowSlug ?? Show!.Slug, SeasonNumber, EpisodeNumber, AbsoluteNumber);
return GetSlug(ShowId.ToString(), SeasonNumber, EpisodeNumber, AbsoluteNumber);
}
private set
@ -302,4 +297,3 @@ namespace Kyoo.Abstractions.Models
};
}
}
}

View File

@ -18,8 +18,8 @@
using System;
namespace Kyoo.Abstractions.Models
{
namespace Kyoo.Abstractions.Models;
/// <summary>
/// An interface applied to resources.
/// </summary>
@ -30,4 +30,3 @@ namespace Kyoo.Abstractions.Models
/// </summary>
public DateTime AddedDate { get; set; }
}
}

View File

@ -18,8 +18,8 @@
using System.Collections.Generic;
namespace Kyoo.Abstractions.Models
{
namespace Kyoo.Abstractions.Models;
/// <summary>
/// An interface applied to resources containing external metadata.
/// </summary>
@ -30,4 +30,3 @@ namespace Kyoo.Abstractions.Models
/// </summary>
public Dictionary<string, MetadataId> ExternalId { get; set; }
}
}

View File

@ -20,8 +20,8 @@ using System;
using System.ComponentModel.DataAnnotations;
using Kyoo.Abstractions.Controllers;
namespace Kyoo.Abstractions.Models
{
namespace Kyoo.Abstractions.Models;
/// <summary>
/// An interface to represent a resource that can be retrieved from the database.
/// </summary>
@ -47,4 +47,3 @@ namespace Kyoo.Abstractions.Models
[MaxLength(256)]
public string Slug { get; }
}
}

View File

@ -23,8 +23,8 @@ using System.Globalization;
using System.Text.Json.Serialization;
using Kyoo.Abstractions.Models.Attributes;
namespace Kyoo.Abstractions.Models
{
namespace Kyoo.Abstractions.Models;
/// <summary>
/// An interface representing items that contains images (like posters, thumbnails, logo, banners...)
/// </summary>
@ -94,10 +94,7 @@ namespace Kyoo.Abstractions.Models
}
/// <inheritdoc />
public override bool CanConvertTo(
ITypeDescriptorContext? context,
Type? destinationType
)
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType)
{
return false;
}
@ -124,4 +121,3 @@ namespace Kyoo.Abstractions.Models
/// </summary>
High,
}
}

View File

@ -27,8 +27,8 @@ using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models.Attributes;
using Kyoo.Utils;
namespace Kyoo.Abstractions.Models
{
namespace Kyoo.Abstractions.Models;
/// <summary>
/// A series or a movie.
/// </summary>
@ -186,4 +186,3 @@ namespace Kyoo.Abstractions.Models
}
}
}
}

View File

@ -26,8 +26,8 @@ using EntityFrameworkCore.Projectables;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models.Attributes;
namespace Kyoo.Abstractions.Models
{
namespace Kyoo.Abstractions.Models;
/// <summary>
/// A season of a <see cref="Show"/>.
/// </summary>
@ -146,4 +146,3 @@ namespace Kyoo.Abstractions.Models
private int _EpisodesCount => Episodes!.Count;
}
}

View File

@ -27,8 +27,8 @@ using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models.Attributes;
using Kyoo.Utils;
namespace Kyoo.Abstractions.Models
{
namespace Kyoo.Abstractions.Models;
/// <summary>
/// A series or a movie.
/// </summary>
@ -277,4 +277,3 @@ namespace Kyoo.Abstractions.Models
/// </summary>
Planned
}
}

View File

@ -23,8 +23,8 @@ using System.Text.Json.Serialization;
using Kyoo.Abstractions.Controllers;
using Kyoo.Utils;
namespace Kyoo.Abstractions.Models
{
namespace Kyoo.Abstractions.Models;
/// <summary>
/// A studio that make shows.
/// </summary>
@ -78,4 +78,3 @@ namespace Kyoo.Abstractions.Models
}
}
}
}

View File

@ -23,8 +23,8 @@ using System.Text.Json.Serialization;
using Kyoo.Abstractions.Controllers;
using Kyoo.Utils;
namespace Kyoo.Abstractions.Models
{
namespace Kyoo.Abstractions.Models;
/// <summary>
/// A single user of the app.
/// </summary>
@ -114,4 +114,3 @@ namespace Kyoo.Abstractions.Models
/// </summary>
public JwtToken Token { get; set; }
}
}

View File

@ -20,8 +20,8 @@ using System;
using System.Text.Json.Serialization;
using Kyoo.Abstractions.Models.Attributes;
namespace Kyoo.Abstractions.Models
{
namespace Kyoo.Abstractions.Models;
/// <summary>
/// Has the user started watching, is it planned?
/// </summary>
@ -230,4 +230,3 @@ namespace Kyoo.Abstractions.Models
/// </remarks>
public int? WatchedPercent { get; set; }
}
}

View File

@ -18,8 +18,8 @@
using System.Collections.Generic;
namespace Kyoo.Abstractions.Models
{
namespace Kyoo.Abstractions.Models;
/// <summary>
/// Results of a search request.
/// </summary>
@ -51,4 +51,3 @@ namespace Kyoo.Abstractions.Models
public ICollection<T> Items { get; set; }
}
}
}

View File

@ -16,8 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
namespace Kyoo.Authentication.Models
{
namespace Kyoo.Authentication.Models;
/// <summary>
/// List of well known claims of kyoo
/// </summary>
@ -53,4 +53,3 @@ namespace Kyoo.Authentication.Models
/// </summary>
public static string Guid => "guid";
}
}

View File

@ -18,8 +18,8 @@
using Kyoo.Abstractions.Models.Attributes;
namespace Kyoo.Abstractions.Models.Utils
{
namespace Kyoo.Abstractions.Models.Utils;
/// <summary>
/// A class containing constant numbers.
/// </summary>
@ -57,4 +57,3 @@ namespace Kyoo.Abstractions.Models.Utils
/// </summary>
public const string AdminGroup = "4:Admin";
}
}

View File

@ -24,8 +24,8 @@ using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
namespace Kyoo.Abstractions.Models.Utils
{
namespace Kyoo.Abstractions.Models.Utils;
/// <summary>
/// A class that represent a resource. It is made to be used as a parameter in a query and not used somewhere else
/// on the application.
@ -162,9 +162,7 @@ namespace Kyoo.Abstractions.Models.Utils
public Filter<T> IsSame<T>()
where T : IResource
{
return _id.HasValue
? new Filter<T>.Eq("Id", _id.Value)
: new Filter<T>.Eq("Slug", _slug!);
return _id.HasValue ? new Filter<T>.Eq("Id", _id.Value) : new Filter<T>.Eq("Slug", _slug!);
}
public bool Is(Guid uid)
@ -245,4 +243,3 @@ namespace Kyoo.Abstractions.Models.Utils
}
}
}
}

View File

@ -18,8 +18,8 @@
using System;
namespace Kyoo.Abstractions.Controllers
{
namespace Kyoo.Abstractions.Controllers;
/// <summary>
/// Information about the pagination. How many items should be displayed and where to start.
/// </summary>
@ -70,4 +70,3 @@ namespace Kyoo.Abstractions.Controllers
/// <returns>A new <see cref="Pagination"/> instance</returns>
public static implicit operator Pagination(int limit) => new(limit);
}
}

View File

@ -19,8 +19,8 @@
using System;
using System.Linq;
namespace Kyoo.Abstractions.Models.Utils
{
namespace Kyoo.Abstractions.Models.Utils;
/// <summary>
/// The list of errors that where made in the request.
/// </summary>
@ -50,11 +50,7 @@ namespace Kyoo.Abstractions.Models.Utils
public RequestError(string[] errors)
{
if (errors == null || !errors.Any())
throw new ArgumentException(
"Errors must be non null and not empty",
nameof(errors)
);
throw new ArgumentException("Errors must be non null and not empty", nameof(errors));
Errors = errors;
}
}
}

View File

@ -16,8 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
namespace Kyoo.Abstractions.Controllers
{
namespace Kyoo.Abstractions.Controllers;
/// <summary>
/// Information about the pagination. How many items should be displayed and where to start.
/// </summary>
@ -33,4 +33,3 @@ namespace Kyoo.Abstractions.Controllers
/// </summary>
public int? Skip { get; set; }
}
}

View File

@ -25,8 +25,8 @@ using Kyoo.Abstractions.Models;
using Kyoo.Abstractions.Models.Attributes;
using Kyoo.Utils;
namespace Kyoo.Abstractions.Controllers
{
namespace Kyoo.Abstractions.Controllers;
public record Sort;
/// <summary>
@ -117,8 +117,7 @@ namespace Kyoo.Abstractions.Controllers
)
};
Type[] types =
typeof(T).GetCustomAttribute<OneOfAttribute>()?.Types ?? new[] { typeof(T) };
Type[] types = typeof(T).GetCustomAttribute<OneOfAttribute>()?.Types ?? new[] { typeof(T) };
PropertyInfo? property = types
.Select(x =>
x.GetProperty(
@ -132,4 +131,3 @@ namespace Kyoo.Abstractions.Controllers
return new By(property.Name, desendant);
}
}
}

View File

@ -16,8 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
namespace Kyoo.Abstractions.Models
{
namespace Kyoo.Abstractions.Models;
/// <summary>
/// The links to see a movie or an episode.
/// </summary>
@ -33,4 +33,3 @@ namespace Kyoo.Abstractions.Models
/// </summary>
public string Hls { get; set; }
}
}

View File

@ -21,8 +21,8 @@ using Autofac.Builder;
using Kyoo.Abstractions.Controllers;
using Kyoo.Utils;
namespace Kyoo.Abstractions
{
namespace Kyoo.Abstractions;
/// <summary>
/// A static class with helper functions to setup external modules
/// </summary>
@ -73,4 +73,3 @@ namespace Kyoo.Abstractions
return builder.RegisterRepository<T2>().AsSelf().As<T>();
}
}
}

View File

@ -19,8 +19,8 @@
using System;
using System.Collections.Generic;
namespace Kyoo.Utils
{
namespace Kyoo.Utils;
/// <summary>
/// A set of extensions class for enumerable.
/// </summary>
@ -68,4 +68,3 @@ namespace Kyoo.Utils
action(i);
}
}
}

View File

@ -22,8 +22,8 @@ using System.Linq;
using System.Reflection;
using Kyoo.Abstractions.Models.Attributes;
namespace Kyoo.Utils
{
namespace Kyoo.Utils;
/// <summary>
/// A class containing helper methods to merge objects.
/// </summary>
@ -131,4 +131,3 @@ namespace Kyoo.Utils
return first;
}
}
}

View File

@ -25,8 +25,8 @@ using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
namespace Kyoo.Utils
{
namespace Kyoo.Utils;
/// <summary>
/// A set of utility functions that can be used everywhere.
/// </summary>
@ -204,9 +204,7 @@ namespace Kyoo.Utils
: type.GetInheritanceTree();
return types
.Prepend(type)
.FirstOrDefault(x =>
x.IsGenericType && x.GetGenericTypeDefinition() == genericType
);
.FirstOrDefault(x => x.IsGenericType && x.GetGenericTypeDefinition() == genericType);
}
/// <summary>
@ -362,4 +360,3 @@ namespace Kyoo.Utils
return "?" + string.Join('&', query.Select(x => $"{x.Key}={x.Value}"));
}
}
}

View File

@ -32,8 +32,8 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
using Microsoft.IdentityModel.Tokens;
namespace Kyoo.Authentication
{
namespace Kyoo.Authentication;
/// <summary>
/// A module that enable OpenID authentication for Kyoo.
/// </summary>
@ -78,10 +78,7 @@ namespace Kyoo.Authentication
NewUser = _configuration
.GetValue("DEFAULT_PERMISSIONS", "overall.read,overall.play")!
.Split(','),
RequireVerification = _configuration.GetValue(
"REQUIRE_ACCOUNT_VERIFICATION",
true
),
RequireVerification = _configuration.GetValue("REQUIRE_ACCOUNT_VERIFICATION", true),
PublicUrl =
_configuration.GetValue<string?>("PUBLIC_URL") ?? "http://localhost:8901",
ApiKeys = _configuration.GetValue("KYOO_APIKEYS", string.Empty)!.Split(','),
@ -154,10 +151,7 @@ namespace Kyoo.Authentication
{
string prefix = "Bearer ";
if (
ctx.Request.Headers.TryGetValue(
"Authorization",
out StringValues val
)
ctx.Request.Headers.TryGetValue("Authorization", out StringValues val)
&& val.ToString() is string auth
&& auth.StartsWith(prefix)
)
@ -186,4 +180,3 @@ namespace Kyoo.Authentication
SA.New<IApplicationBuilder>(app => app.UseAuthentication(), SA.Authentication),
};
}
}

View File

@ -21,8 +21,8 @@ using System.Threading.Tasks;
using Kyoo.Abstractions.Models;
using Microsoft.IdentityModel.Tokens;
namespace Kyoo.Authentication
{
namespace Kyoo.Authentication;
/// <summary>
/// The service that controls jwt creation and validation.
/// </summary>
@ -51,4 +51,3 @@ namespace Kyoo.Authentication
/// <returns>The id of the token's user.</returns>
Guid GetRefreshTokenUserID(string refreshToken);
}
}

View File

@ -32,8 +32,8 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Primitives;
namespace Kyoo.Authentication
{
namespace Kyoo.Authentication;
/// <summary>
/// A permission validator to validate permission with user Permission array
/// or the default array from the configurations if the user is not logged.
@ -126,11 +126,7 @@ namespace Kyoo.Authentication
/// <param name="partialInfo">The partial permission to validate.</param>
/// <param name="group">The group of the permission.</param>
/// <param name="options">The option containing default values.</param>
public PermissionValidatorFilter(
object partialInfo,
Group? group,
PermissionOption options
)
public PermissionValidatorFilter(object partialInfo, Group? group, PermissionOption options)
{
switch (partialInfo)
{
@ -159,11 +155,7 @@ namespace Kyoo.Authentication
if (permission == null || kind == null)
{
if (
context.HttpContext.Items["PermissionGroup"]
is Group group
and not Group.None
)
if (context.HttpContext.Items["PermissionGroup"] is Group group and not Group.None)
_group = group;
else if (_group == Group.None)
_group = Group.Overall;
@ -226,10 +218,7 @@ namespace Kyoo.Authentication
}
}
else if (res.Failure != null)
context.Result = _ErrorResult(
res.Failure.Message,
StatusCodes.Status403Forbidden
);
context.Result = _ErrorResult(res.Failure.Message, StatusCodes.Status403Forbidden);
else
context.Result = _ErrorResult(
"Authentication panic",
@ -277,9 +266,7 @@ namespace Kyoo.Authentication
);
// Change the failure message to make the API nice to use.
if (ret.Failure != null)
return AuthenticateResult.Fail(
"Invalid JWT token. The token may have expired."
);
return AuthenticateResult.Fail("Invalid JWT token. The token may have expired.");
return ret;
}
}
@ -295,4 +282,3 @@ namespace Kyoo.Authentication
return new ObjectResult(new RequestError(error)) { StatusCode = code };
}
}
}

View File

@ -27,8 +27,8 @@ using Kyoo.Abstractions.Models;
using Kyoo.Authentication.Models;
using Microsoft.IdentityModel.Tokens;
namespace Kyoo.Authentication
{
namespace Kyoo.Authentication;
/// <summary>
/// The service that controls jwt creation and validation.
/// </summary>
@ -132,4 +132,3 @@ namespace Kyoo.Authentication
throw new SecurityTokenException("Token not associated to any user.");
}
}
}

View File

@ -16,8 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
namespace Kyoo.Authentication.Models.DTO
{
namespace Kyoo.Authentication.Models.DTO;
/// <summary>
/// A model only used on login requests.
/// </summary>
@ -44,4 +44,3 @@ namespace Kyoo.Authentication.Models.DTO
Password = password;
}
}
}

View File

@ -21,8 +21,8 @@ using Kyoo.Abstractions.Models;
using Kyoo.Utils;
using BCryptNet = BCrypt.Net.BCrypt;
namespace Kyoo.Authentication.Models.DTO
{
namespace Kyoo.Authentication.Models.DTO;
/// <summary>
/// A model only used on register requests.
/// </summary>
@ -74,4 +74,3 @@ namespace Kyoo.Authentication.Models.DTO
};
}
}
}

View File

@ -16,8 +16,8 @@
// You should have received a copy of the GNU General Public License
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
namespace Kyoo.Authentication.Models
{
namespace Kyoo.Authentication.Models;
/// <summary>
/// The main authentication options.
/// </summary>
@ -43,4 +43,3 @@ namespace Kyoo.Authentication.Models
/// </summary>
public PermissionOption Permissions { get; set; } = new();
}
}

View File

@ -35,8 +35,8 @@ using Microsoft.IdentityModel.Tokens;
using static Kyoo.Abstractions.Models.Utils.Constants;
using BCryptNet = BCrypt.Net.BCrypt;
namespace Kyoo.Authentication.Views
{
namespace Kyoo.Authentication.Views;
/// <summary>
/// Sign in, Sign up or refresh tokens.
/// </summary>
@ -127,12 +127,7 @@ namespace Kyoo.Authentication.Views
/// <response code="403">The provider gave an error.</response>
[HttpGet("logged/{provider}")]
[ProducesResponseType(StatusCodes.Status302Found)]
public ActionResult OauthCodeRedirect(
string provider,
string code,
string state,
string? error
)
public ActionResult OauthCodeRedirect(string provider, string code, string state, string? error)
{
return Redirect(
_BuildUrl(
@ -495,4 +490,3 @@ namespace Kyoo.Authentication.Views
return NoContent();
}
}
}

View File

@ -20,8 +20,8 @@ using Kyoo.Abstractions.Models.Utils;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
namespace Kyoo.Core.Controllers
{
namespace Kyoo.Core.Controllers;
/// <summary>
/// The route constraint that goes with the <see cref="Identifier"/>.
/// </summary>
@ -39,4 +39,3 @@ namespace Kyoo.Core.Controllers
return values.ContainsKey(routeKey);
}
}
}

View File

@ -20,8 +20,8 @@ using System.Linq;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
namespace Kyoo.Core.Controllers
{
namespace Kyoo.Core.Controllers;
/// <summary>
/// An class to interact with the database. Every repository is mapped through here.
/// </summary>
@ -103,4 +103,3 @@ namespace Kyoo.Core.Controllers
return (IRepository<T>)_repositories.First(x => x.RepositoryType == typeof(T));
}
}
}

View File

@ -26,8 +26,8 @@ using Kyoo.Abstractions.Models.Utils;
using Kyoo.Postgresql;
using Microsoft.EntityFrameworkCore;
namespace Kyoo.Core.Controllers
{
namespace Kyoo.Core.Controllers;
/// <summary>
/// A local repository to handle collections
/// </summary>
@ -100,4 +100,3 @@ namespace Kyoo.Core.Controllers
await base.Delete(obj);
}
}
}

View File

@ -27,8 +27,8 @@ using Kyoo.Postgresql;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Kyoo.Core.Controllers
{
namespace Kyoo.Core.Controllers;
/// <summary>
/// A local repository to handle episodes.
/// </summary>
@ -47,8 +47,7 @@ namespace Kyoo.Core.Controllers
IRepository<Show>.OnEdited += async (show) =>
{
await using AsyncServiceScope scope = CoreModule.Services.CreateAsyncScope();
DatabaseContext database =
scope.ServiceProvider.GetRequiredService<DatabaseContext>();
DatabaseContext database = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
List<Episode> episodes = await database
.Episodes.AsTracking()
.Where(x => x.ShowId == show.Id)
@ -153,4 +152,3 @@ namespace Kyoo.Core.Controllers
await _shows.Delete(obj.ShowId);
}
}
}

View File

@ -25,8 +25,8 @@ using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
using Kyoo.Abstractions.Models.Utils;
namespace Kyoo.Core.Controllers
{
namespace Kyoo.Core.Controllers;
/// <summary>
/// A local repository to handle library items.
/// </summary>
@ -124,4 +124,3 @@ namespace Kyoo.Core.Controllers
);
}
}
}

View File

@ -32,8 +32,8 @@ using Kyoo.Postgresql;
using Kyoo.Utils;
using Microsoft.EntityFrameworkCore;
namespace Kyoo.Core.Controllers
{
namespace Kyoo.Core.Controllers;
/// <summary>
/// A base class to create repositories using Entity Framework.
/// </summary>
@ -170,9 +170,7 @@ namespace Kyoo.Core.Controllers
{
T? ret = await GetOrDefault(filter, include, sortBy, reverse, afterId);
if (ret == null)
throw new ItemNotFoundException(
$"No {typeof(T).Name} found with the given predicate."
);
throw new ItemNotFoundException($"No {typeof(T).Name} found with the given predicate.");
return ret;
}
@ -244,13 +242,7 @@ namespace Kyoo.Core.Controllers
Pagination? limit = default
)
{
IQueryable<T> query = await ApplyFilters(
Database.Set<T>(),
filter,
sort,
limit,
include
);
IQueryable<T> query = await ApplyFilters(Database.Set<T>(), filter, sort, limit, include);
return await query.ToListAsync();
}
@ -435,9 +427,8 @@ namespace Kyoo.Core.Controllers
protected virtual Task Validate(T resource)
{
if (
typeof(T)
.GetProperty(nameof(resource.Slug))!
.GetCustomAttribute<ComputedAttribute>() != null
typeof(T).GetProperty(nameof(resource.Slug))!.GetCustomAttribute<ComputedAttribute>()
!= null
)
return Task.CompletedTask;
if (string.IsNullOrEmpty(resource.Slug))
@ -446,9 +437,7 @@ namespace Kyoo.Core.Controllers
{
try
{
MethodInfo? setter = typeof(T)
.GetProperty(nameof(resource.Slug))!
.GetSetMethod();
MethodInfo? setter = typeof(T).GetProperty(nameof(resource.Slug))!.GetSetMethod();
if (setter != null)
setter.Invoke(resource, new object[] { resource.Slug + '!' });
else
@ -496,4 +485,3 @@ namespace Kyoo.Core.Controllers
await Delete(resource);
}
}
}

View File

@ -25,8 +25,8 @@ using Kyoo.Abstractions.Models.Utils;
using Kyoo.Postgresql;
using Microsoft.EntityFrameworkCore;
namespace Kyoo.Core.Controllers
{
namespace Kyoo.Core.Controllers;
/// <summary>
/// A local repository to handle shows
/// </summary>
@ -106,4 +106,3 @@ namespace Kyoo.Core.Controllers
await base.Delete(obj);
}
}
}

View File

@ -22,8 +22,8 @@ using System.Data.Common;
using System.IO;
using Kyoo.Abstractions.Models;
namespace Kyoo.Core.Controllers
{
namespace Kyoo.Core.Controllers;
/// <summary>
/// A local repository to handle shows
/// </summary>
@ -61,4 +61,3 @@ namespace Kyoo.Core.Controllers
public NewsRepository(DbConnection database, SqlVariableContext context)
: base(database, context) { }
}
}

View File

@ -29,8 +29,8 @@ using Kyoo.Postgresql;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace Kyoo.Core.Controllers
{
namespace Kyoo.Core.Controllers;
/// <summary>
/// A local repository to handle seasons.
/// </summary>
@ -47,8 +47,7 @@ namespace Kyoo.Core.Controllers
IRepository<Show>.OnEdited += async (show) =>
{
await using AsyncServiceScope scope = CoreModule.Services.CreateAsyncScope();
DatabaseContext database =
scope.ServiceProvider.GetRequiredService<DatabaseContext>();
DatabaseContext database = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
List<Season> seasons = await database
.Seasons.AsTracking()
.Where(x => x.ShowId == show.Id)
@ -130,4 +129,3 @@ namespace Kyoo.Core.Controllers
await base.Delete(obj);
}
}
}

View File

@ -26,8 +26,8 @@ using Kyoo.Postgresql;
using Kyoo.Utils;
using Microsoft.EntityFrameworkCore;
namespace Kyoo.Core.Controllers
{
namespace Kyoo.Core.Controllers;
/// <summary>
/// A local repository to handle shows
/// </summary>
@ -107,4 +107,3 @@ namespace Kyoo.Core.Controllers
await base.Delete(obj);
}
}
}

View File

@ -26,8 +26,8 @@ using Kyoo.Postgresql;
using Kyoo.Utils;
using Microsoft.EntityFrameworkCore;
namespace Kyoo.Core.Controllers
{
namespace Kyoo.Core.Controllers;
/// <summary>
/// A local repository to handle studios
/// </summary>
@ -79,4 +79,3 @@ namespace Kyoo.Core.Controllers
await base.Delete(obj);
}
}
}

View File

@ -31,8 +31,8 @@ using Kyoo.Abstractions.Models.Exceptions;
using Microsoft.Extensions.Logging;
using SkiaSharp;
namespace Kyoo.Core.Controllers
{
namespace Kyoo.Core.Controllers;
/// <summary>
/// Download images and retrieve the path of those images for a resource.
/// </summary>
@ -42,8 +42,7 @@ namespace Kyoo.Core.Controllers
Lazy<IRepository<User>> users
) : IThumbnailsManager
{
private static readonly Dictionary<string, TaskCompletionSource<object>> _downloading =
new();
private static readonly Dictionary<string, TaskCompletionSource<object>> _downloading = new();
private static async Task _WriteTo(SKBitmap bitmap, string path, int quality)
{
@ -265,4 +264,3 @@ namespace Kyoo.Core.Controllers
await _WriteTo(ret, $"/metadata/user/{userId}.webp", 75);
}
}
}

View File

@ -33,8 +33,8 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
namespace Kyoo.Core
{
namespace Kyoo.Core;
/// <summary>
/// The core module containing default implementations
/// </summary>
@ -145,4 +145,3 @@ namespace Kyoo.Core
)
};
}
}

View File

@ -25,8 +25,8 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
namespace Kyoo.Core
{
namespace Kyoo.Core;
/// <summary>
/// A middleware to handle errors globally.
/// </summary>
@ -80,4 +80,3 @@ namespace Kyoo.Core
}
}
}
}

View File

@ -22,8 +22,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace Kyoo.Core.Api
{
namespace Kyoo.Core.Api;
/// <summary>
/// An API endpoint to check the health.
/// </summary>
@ -72,4 +72,3 @@ namespace Kyoo.Core.Api
/// </summary>
public record HealthResult(string Status);
}
}

View File

@ -25,8 +25,8 @@ using Kyoo.Abstractions.Models;
using Kyoo.Utils;
using Microsoft.AspNetCore.Mvc;
namespace Kyoo.Core.Api
{
namespace Kyoo.Core.Api;
/// <summary>
/// A common API containing custom methods to help inheritors.
/// </summary>
@ -97,4 +97,3 @@ namespace Kyoo.Core.Api
return new SearchPage<TResult>(result, self, previous, next, first);
}
}
}

View File

@ -27,8 +27,8 @@ using Kyoo.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Kyoo.Core.Api
{
namespace Kyoo.Core.Api;
/// <summary>
/// A base class to handle CRUD operations on a specific resource type <typeparamref name="T"/>.
/// </summary>
@ -67,10 +67,7 @@ namespace Kyoo.Core.Api
[PartialPermission(Kind.Read)]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<T>> Get(
Identifier identifier,
[FromQuery] Include<T>? fields
)
public async Task<ActionResult<T>> Get(Identifier identifier, [FromQuery] Include<T>? fields)
{
T? ret = await identifier.Match(
id => Repository.GetOrDefault(id, fields),
@ -273,4 +270,3 @@ namespace Kyoo.Core.Api
return NoContent();
}
}
}

View File

@ -26,8 +26,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Core.Api
{
namespace Kyoo.Core.Api;
/// <summary>
/// A base class to handle CRUD operations and services thumbnails for
/// a specific resource type <typeparamref name="T"/>.
@ -97,10 +97,7 @@ namespace Kyoo.Core.Api
[PartialPermission(Kind.Read)]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public Task<IActionResult> GetPoster(
Identifier identifier,
[FromQuery] ImageQuality? quality
)
public Task<IActionResult> GetPoster(Identifier identifier, [FromQuery] ImageQuality? quality)
{
return _GetImage(identifier, "poster", quality);
}
@ -140,12 +137,8 @@ namespace Kyoo.Core.Api
/// </response>
[HttpGet("{identifier:id}/thumbnail")]
[HttpGet("{identifier:id}/backdrop", Order = AlternativeRoute)]
public Task<IActionResult> GetBackdrop(
Identifier identifier,
[FromQuery] ImageQuality? quality
)
public Task<IActionResult> GetBackdrop(Identifier identifier, [FromQuery] ImageQuality? quality)
{
return _GetImage(identifier, "thumbnail", quality);
}
}
}

View File

@ -28,8 +28,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Core.Api
{
namespace Kyoo.Core.Api;
/// <summary>
/// Information about one or multiple <see cref="Studio"/>.
/// </summary>
@ -100,4 +100,3 @@ namespace Kyoo.Core.Api
return Page(resources, pagination.Limit);
}
}
}

View File

@ -30,8 +30,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Core.Api
{
namespace Kyoo.Core.Api;
/// <summary>
/// Information about one or multiple <see cref="Collection"/>.
/// </summary>
@ -260,4 +260,3 @@ namespace Kyoo.Core.Api
return Page(resources, pagination.Limit);
}
}
}

View File

@ -28,8 +28,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Core.Api
{
namespace Kyoo.Core.Api;
/// <summary>
/// Information about one or multiple <see cref="Episode"/>.
/// </summary>
@ -196,4 +196,3 @@ namespace Kyoo.Core.Api
return (path, $"/episodes/{identifier}");
}
}
}

View File

@ -23,8 +23,8 @@ using Kyoo.Abstractions.Models.Permissions;
using Microsoft.AspNetCore.Mvc;
using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Core.Api
{
namespace Kyoo.Core.Api;
/// <summary>
/// Endpoint for items that are not part of a specific library.
/// An item can ether represent a collection or a show.
@ -54,4 +54,3 @@ namespace Kyoo.Core.Api
_libraryItems = libraryItems;
}
}
}

View File

@ -30,8 +30,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Core.Api
{
namespace Kyoo.Core.Api;
/// <summary>
/// Information about one or multiple <see cref="Movie"/>.
/// </summary>
@ -208,4 +208,3 @@ namespace Kyoo.Core.Api
return (path, $"/movies/{identifier}");
}
}
}

View File

@ -23,8 +23,8 @@ using Kyoo.Abstractions.Models.Permissions;
using Microsoft.AspNetCore.Mvc;
using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Core.Api
{
namespace Kyoo.Core.Api;
/// <summary>
/// List new items added to kyoo.
/// </summary>
@ -38,4 +38,3 @@ namespace Kyoo.Core.Api
public NewsApi(IRepository<INews> news, IThumbnailsManager thumbs)
: base(news, thumbs) { }
}
}

View File

@ -26,8 +26,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Core.Api
{
namespace Kyoo.Core.Api;
/// <summary>
/// An endpoint to search for every resources of kyoo. Searching for only a specific type of resource
/// is available on the said endpoint.
@ -69,9 +69,7 @@ namespace Kyoo.Core.Api
[FromQuery] Include<Collection> fields
)
{
return SearchPage(
await _searchManager.SearchCollections(q, sortBy, pagination, fields)
);
return SearchPage(await _searchManager.SearchCollections(q, sortBy, pagination, fields));
}
/// <summary>
@ -204,4 +202,3 @@ namespace Kyoo.Core.Api
return SearchPage(await _searchManager.SearchStudios(q, sortBy, pagination, fields));
}
}
}

View File

@ -28,8 +28,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Core.Api
{
namespace Kyoo.Core.Api;
/// <summary>
/// Information about one or multiple <see cref="Season"/>.
/// </summary>
@ -87,10 +87,7 @@ namespace Kyoo.Core.Api
)
{
ICollection<Episode> resources = await _libraryManager.Episodes.GetAll(
Filter.And(
filter,
identifier.Matcher<Episode>(x => x.SeasonId, x => x.Season!.Slug)
),
Filter.And(filter, identifier.Matcher<Episode>(x => x.SeasonId, x => x.Season!.Slug)),
sortBy,
fields,
pagination
@ -132,4 +129,3 @@ namespace Kyoo.Core.Api
return ret;
}
}
}

View File

@ -30,8 +30,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Core.Api
{
namespace Kyoo.Core.Api;
/// <summary>
/// Information about one or multiple <see cref="Show"/>.
/// </summary>
@ -256,10 +256,7 @@ namespace Kyoo.Core.Api
[ProducesResponseType(StatusCodes.Status204NoContent)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ShowWatchStatus?> SetWatchStatus(
Identifier identifier,
WatchStatus status
)
public async Task<ShowWatchStatus?> SetWatchStatus(Identifier identifier, WatchStatus status)
{
Guid id = await identifier.Match(
id => Task.FromResult(id),
@ -291,4 +288,3 @@ namespace Kyoo.Core.Api
await _libraryManager.WatchStatus.DeleteShowStatus(id, User.GetIdOrThrow());
}
}
}

View File

@ -29,8 +29,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Core.Api
{
namespace Kyoo.Core.Api;
/// <summary>
/// List new items added to kyoo.
/// </summary>
@ -69,4 +69,3 @@ namespace Kyoo.Core.Api
return Page(resources, pagination.Limit);
}
}
}

View File

@ -28,8 +28,8 @@ using Kyoo.Utils;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Kyoo.Core.Api
{
namespace Kyoo.Core.Api;
/// <summary>
/// Proxy to other services
/// </summary>
@ -93,4 +93,3 @@ namespace Kyoo.Core.Api
await _Proxy(rest + query.ToQueryString(), (path, $"{type}/{id}"));
}
}
}

View File

@ -37,8 +37,8 @@ using Serilog.Templates;
using Serilog.Templates.Themes;
using ILogger = Serilog.ILogger;
namespace Kyoo.Host
{
namespace Kyoo.Host;
/// <summary>
/// Hosts of kyoo (main functions) generally only create a new <see cref="Application"/>
/// and return <see cref="Start(string[])"/>.
@ -124,10 +124,7 @@ namespace Kyoo.Host
"Version: {Version}",
Assembly.GetExecutingAssembly().GetName().Version.ToString(3)
);
_logger.Information(
"Data directory: {DataDirectory}",
Environment.CurrentDirectory
);
_logger.Information("Data directory: {DataDirectory}", Environment.CurrentDirectory);
await host.RunAsync(cancellationToken);
}
catch (Exception ex)
@ -157,9 +154,7 @@ namespace Kyoo.Host
})
.UseIIS()
.UseIISIntegration()
.UseUrls(
Environment.GetEnvironmentVariable("KYOO_BIND_URL") ?? "http://*:5000"
)
.UseUrls(Environment.GetEnvironmentVariable("KYOO_BIND_URL") ?? "http://*:5000")
.UseStartup(host =>
PluginsStartup.FromWebHost(host, new LoggerFactory().AddSerilog())
)
@ -199,4 +194,3 @@ namespace Kyoo.Host
.Enrich.FromLogContext();
}
}
}

View File

@ -23,8 +23,8 @@ using Kyoo.Abstractions.Controllers;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Kyoo.Host.Controllers
{
namespace Kyoo.Host.Controllers;
/// <summary>
/// An implementation of <see cref="IPluginManager"/>.
/// This is used to load plugins and retrieve information from them.
@ -86,10 +86,7 @@ namespace Kyoo.Host.Controllers
public void LoadPlugins(params Type[] plugins)
{
LoadPlugins(
plugins
.Select(x => (IPlugin)ActivatorUtilities.CreateInstance(_provider, x))
.ToArray()
plugins.Select(x => (IPlugin)ActivatorUtilities.CreateInstance(_provider, x)).ToArray()
);
}
}
}

View File

@ -23,8 +23,8 @@ using Kyoo.Abstractions.Controllers;
using Microsoft.AspNetCore.Builder;
using Serilog;
namespace Kyoo.Host
{
namespace Kyoo.Host;
/// <summary>
/// A module that registers host controllers and other needed things.
/// </summary>
@ -58,4 +58,3 @@ namespace Kyoo.Host
public IEnumerable<IStartupAction> ConfigureSteps =>
new[] { SA.New<IApplicationBuilder>(app => app.UseSerilogRequestLogging(), SA.Before) };
}
}

View File

@ -36,8 +36,8 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace Kyoo.Host
{
namespace Kyoo.Host;
/// <summary>
/// The Startup class is used to configure the AspNet's webhost.
/// </summary>
@ -81,8 +81,7 @@ namespace Kyoo.Host
/// <returns>A new <see cref="PluginsStartup"/>.</returns>
public static PluginsStartup FromWebHost(WebHostBuilderContext host, ILoggerFactory logger)
{
HostServiceProvider hostProvider =
new(host.HostingEnvironment, host.Configuration, logger);
HostServiceProvider hostProvider = new(host.HostingEnvironment, host.Configuration, logger);
PluginManager plugins = new(hostProvider, logger.CreateLogger<PluginManager>());
return new PluginsStartup(plugins);
}
@ -93,9 +92,7 @@ namespace Kyoo.Host
/// <param name="services">The service collection to fill.</param>
public void ConfigureServices(IServiceCollection services)
{
foreach (
Assembly assembly in _plugins.GetAllPlugins().Select(x => x.GetType().Assembly)
)
foreach (Assembly assembly in _plugins.GetAllPlugins().Select(x => x.GetType().Assembly))
services.AddMvcCore().AddApplicationPart(assembly);
_hostModule.Configure(services);
@ -199,4 +196,3 @@ namespace Kyoo.Host
}
}
}
}

View File

@ -19,8 +19,8 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
namespace Kyoo.Host
{
namespace Kyoo.Host;
/// <summary>
/// Program entrypoint.
/// </summary>
@ -46,4 +46,3 @@ namespace Kyoo.Host
return application.Start(args);
}
}
}

View File

@ -24,8 +24,8 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using static System.Text.Json.JsonNamingPolicy;
namespace Kyoo.Meiliseach
{
namespace Kyoo.Meiliseach;
public class MeilisearchModule : IPlugin
{
/// <inheritdoc />
@ -64,11 +64,7 @@ namespace Kyoo.Meiliseach
CamelCase.ConvertName(nameof(Movie.Rating)),
CamelCase.ConvertName(nameof(Movie.Runtime)),
},
DisplayedAttributes = new[]
{
CamelCase.ConvertName(nameof(Movie.Id)),
"kind"
},
DisplayedAttributes = new[] { CamelCase.ConvertName(nameof(Movie.Id)), "kind" },
RankingRules = new[]
{
"words",
@ -191,4 +187,3 @@ namespace Kyoo.Meiliseach
builder.RegisterType<SearchManager>().As<ISearchManager>().InstancePerLifetimeScope();
}
}
}

View File

@ -31,8 +31,8 @@ using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
namespace Kyoo.Postgresql
{
namespace Kyoo.Postgresql;
/// <summary>
/// The database handle used for all local repositories.
/// This is an abstract class. It is meant to be implemented by plugins. This allow the core to be database agnostic.
@ -260,10 +260,7 @@ namespace Kyoo.Postgresql
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Show>().Ignore(x => x.FirstEpisode).Ignore(x => x.AirDate);
modelBuilder
.Entity<Episode>()
.Ignore(x => x.PreviousEpisode)
.Ignore(x => x.NextEpisode);
modelBuilder.Entity<Episode>().Ignore(x => x.PreviousEpisode).Ignore(x => x.NextEpisode);
modelBuilder
.Entity<Show>()
@ -353,9 +350,7 @@ namespace Kyoo.Postgresql
modelBuilder.Entity<MovieWatchStatus>().HasQueryFilter(x => x.UserId == CurrentUserId);
modelBuilder.Entity<ShowWatchStatus>().HasQueryFilter(x => x.UserId == CurrentUserId);
modelBuilder
.Entity<EpisodeWatchStatus>()
.HasQueryFilter(x => x.UserId == CurrentUserId);
modelBuilder.Entity<EpisodeWatchStatus>().HasQueryFilter(x => x.UserId == CurrentUserId);
modelBuilder.Entity<ShowWatchStatus>().Navigation(x => x.NextEpisode).AutoInclude();
@ -543,9 +538,7 @@ namespace Kyoo.Postgresql
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe while waiting for the task to complete</param>
/// <exception cref="DuplicatedItemException">A duplicated item has been found.</exception>
/// <returns>The number of state entries written to the database.</returns>
public override async Task<int> SaveChangesAsync(
CancellationToken cancellationToken = default
)
public override async Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
{
try
{
@ -635,13 +628,10 @@ namespace Kyoo.Postgresql
public void DiscardChanges()
{
foreach (
EntityEntry entry in ChangeTracker
.Entries()
.Where(x => x.State != EntityState.Detached)
EntityEntry entry in ChangeTracker.Entries().Where(x => x.State != EntityState.Detached)
)
{
entry.State = EntityState.Detached;
}
}
}
}

View File

@ -25,8 +25,8 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Query.SqlExpressions;
using Npgsql;
namespace Kyoo.Postgresql
{
namespace Kyoo.Postgresql;
/// <summary>
/// A postgresql implementation of <see cref="DatabaseContext"/>.
/// </summary>
@ -135,4 +135,3 @@ namespace Kyoo.Postgresql
};
}
}
}

View File

@ -33,8 +33,8 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Npgsql;
namespace Kyoo.Postgresql
{
namespace Kyoo.Postgresql;
/// <summary>
/// A module to add postgresql capacity to the app.
/// </summary>
@ -137,11 +137,8 @@ namespace Kyoo.Postgresql
},
ServiceLifetime.Transient
);
services.AddTransient<DbConnection>(
(_) => new NpgsqlConnection(builder.ConnectionString)
);
services.AddTransient<DbConnection>((_) => new NpgsqlConnection(builder.ConnectionString));
services.AddHealthChecks().AddDbContextCheck<DatabaseContext>();
}
}
}

View File

@ -22,8 +22,8 @@ using Kyoo.Swagger.Models;
using NSwag;
using NSwag.Generation.AspNetCore;
namespace Kyoo.Swagger
{
namespace Kyoo.Swagger;
/// <summary>
/// A class to sort apis.
/// </summary>
@ -63,4 +63,3 @@ namespace Kyoo.Swagger
};
}
}
}

View File

@ -26,8 +26,8 @@ using NSwag;
using NSwag.Generation.AspNetCore;
using NSwag.Generation.Processors.Contexts;
namespace Kyoo.Swagger
{
namespace Kyoo.Swagger;
/// <summary>
/// A class to handle Api Groups (OpenApi tags and x-tagGroups).
/// Tags should be specified via <see cref="ApiDefinitionAttribute"/> and this filter will map this to the
@ -121,4 +121,3 @@ namespace Kyoo.Swagger
options.PostProcess += x => x.AddLeftoversToOthersGroup();
}
}
}

View File

@ -24,8 +24,8 @@ using Kyoo.Utils;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApplicationModels;
namespace Kyoo.Swagger
{
namespace Kyoo.Swagger;
/// <summary>
/// A filter that change <see cref="ProducesResponseTypeAttribute"/>'s
/// <see cref="ProducesResponseTypeAttribute.Type"/> that where set to <see cref="ActionResult{T}"/> to the
@ -66,4 +66,3 @@ namespace Kyoo.Swagger
}
}
}
}

View File

@ -20,8 +20,8 @@ using System.Collections.Generic;
using Newtonsoft.Json;
using NSwag;
namespace Kyoo.Swagger.Models
{
namespace Kyoo.Swagger.Models;
/// <summary>
/// A class representing a group of tags in the <see cref="OpenApiDocument"/>
/// </summary>
@ -39,4 +39,3 @@ namespace Kyoo.Swagger.Models
[JsonProperty(PropertyName = "tags")]
public List<string> Tags { get; set; }
}
}

View File

@ -25,8 +25,8 @@ using NSwag;
using NSwag.Generation.Processors;
using NSwag.Generation.Processors.Contexts;
namespace Kyoo.Swagger
{
namespace Kyoo.Swagger;
/// <summary>
/// An operation processor that adds permissions information from the <see cref="PermissionAttribute"/> and the
/// <see cref="PartialPermissionAttribute"/>.
@ -36,8 +36,7 @@ namespace Kyoo.Swagger
/// <inheritdoc />
public bool Process(OperationProcessorContext context)
{
context.OperationDescription.Operation.Security ??=
new List<OpenApiSecurityRequirement>();
context.OperationDescription.Operation.Security ??= new List<OpenApiSecurityRequirement>();
OpenApiSecurityRequirement perms = context
.MethodInfo.GetCustomAttributes<UserOnlyAttribute>()
.Aggregate(
@ -101,4 +100,3 @@ namespace Kyoo.Swagger
: new List<string>();
}
}
}

View File

@ -29,8 +29,8 @@ using NSwag;
using NSwag.Generation.AspNetCore;
using static Kyoo.Abstractions.Models.Utils.Constants;
namespace Kyoo.Swagger
{
namespace Kyoo.Swagger;
/// <summary>
/// A module to enable a swagger interface and an OpenAPI endpoint to document Kyoo.
/// </summary>
@ -128,4 +128,3 @@ namespace Kyoo.Swagger
)
};
}
}