mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-05 14:44:46 -04:00
Fix merge and build
This commit is contained in:
parent
829eb1a849
commit
ec3e15db57
@ -1,8 +1,4 @@
|
|||||||
<<<<<<< HEAD
|
|
||||||
using System;
|
|
||||||
=======
|
|
||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
>>>>>>> origin/master
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace Jellyfin.Api
|
namespace Jellyfin.Api
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
|
#nullable enable
|
||||||
|
#pragma warning disable CA1801
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Linq;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
|
using Jellyfin.Data.Entities;
|
||||||
using MediaBrowser.Model.Activity;
|
using MediaBrowser.Model.Activity;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
@ -44,7 +48,10 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[FromQuery] DateTime? minDate,
|
[FromQuery] DateTime? minDate,
|
||||||
bool? hasUserId)
|
bool? hasUserId)
|
||||||
{
|
{
|
||||||
return _activityManager.GetActivityLogEntries(minDate, hasUserId, startIndex, limit);
|
var filterFunc = new Func<IQueryable<ActivityLog>, IQueryable<ActivityLog>>(
|
||||||
|
entries => entries.Where(entry => entry.DateCreated >= minDate));
|
||||||
|
|
||||||
|
return _activityManager.GetPagedResult(filterFunc, startIndex, limit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#nullable enable
|
||||||
|
|
||||||
namespace Jellyfin.Api.Models.ConfigurationDtos
|
namespace Jellyfin.Api.Models.ConfigurationDtos
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -8,11 +10,11 @@ namespace Jellyfin.Api.Models.ConfigurationDtos
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets media encoder path.
|
/// Gets or sets media encoder path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Path { get; set; }
|
public string Path { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets media encoder path type.
|
/// Gets or sets media encoder path type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PathType { get; set; }
|
public string PathType { get; set; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ namespace Jellyfin.Server.Extensions
|
|||||||
.AddJsonOptions(options =>
|
.AddJsonOptions(options =>
|
||||||
{
|
{
|
||||||
// Update all properties that are set in JsonDefaults
|
// Update all properties that are set in JsonDefaults
|
||||||
var jsonOptions = JsonDefaults.PascalCase;
|
var jsonOptions = JsonDefaults.GetPascalCaseOptions();
|
||||||
|
|
||||||
// From JsonDefaults
|
// From JsonDefaults
|
||||||
options.JsonSerializerOptions.ReadCommentHandling = jsonOptions.ReadCommentHandling;
|
options.JsonSerializerOptions.ReadCommentHandling = jsonOptions.ReadCommentHandling;
|
||||||
|
@ -12,7 +12,7 @@ namespace Jellyfin.Server.Formatters
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="CamelCaseJsonProfileFormatter"/> class.
|
/// Initializes a new instance of the <see cref="CamelCaseJsonProfileFormatter"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CamelCaseJsonProfileFormatter() : base(JsonDefaults.CamelCase)
|
public CamelCaseJsonProfileFormatter() : base(JsonDefaults.GetCamelCaseOptions())
|
||||||
{
|
{
|
||||||
SupportedMediaTypes.Clear();
|
SupportedMediaTypes.Clear();
|
||||||
SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json;profile=\"CamelCase\""));
|
SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json;profile=\"CamelCase\""));
|
||||||
|
@ -12,7 +12,7 @@ namespace Jellyfin.Server.Formatters
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="PascalCaseJsonProfileFormatter"/> class.
|
/// Initializes a new instance of the <see cref="PascalCaseJsonProfileFormatter"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PascalCaseJsonProfileFormatter() : base(JsonDefaults.PascalCase)
|
public PascalCaseJsonProfileFormatter() : base(JsonDefaults.GetPascalCaseOptions())
|
||||||
{
|
{
|
||||||
SupportedMediaTypes.Clear();
|
SupportedMediaTypes.Clear();
|
||||||
// Add application/json for default formatter
|
// Add application/json for default formatter
|
||||||
|
@ -14,10 +14,6 @@
|
|||||||
<Compile Include="..\SharedVersion.cs" />
|
<Compile Include="..\SharedVersion.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Attachments" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.1</TargetFramework>
|
<TargetFramework>netstandard2.1</TargetFramework>
|
||||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Linq;
|
|
||||||
using Jellyfin.Data.Entities;
|
|
||||||
using MediaBrowser.Controller.Configuration;
|
|
||||||
using MediaBrowser.Controller.Net;
|
|
||||||
using MediaBrowser.Model.Activity;
|
|
||||||
using MediaBrowser.Model.Querying;
|
|
||||||
using MediaBrowser.Model.Services;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Api.System
|
|
||||||
{
|
|
||||||
[Route("/System/ActivityLog/Entries", "GET", Summary = "Gets activity log entries")]
|
|
||||||
public class GetActivityLogs : IReturn<QueryResult<ActivityLogEntry>>
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Skips over a given number of items within the results. Use for paging.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The start index.</value>
|
|
||||||
[ApiMember(Name = "StartIndex", Description = "Optional. The record index to start at. All items with a lower index will be dropped from the results.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
|
||||||
public int? StartIndex { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The maximum number of items to return
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The limit.</value>
|
|
||||||
[ApiMember(Name = "Limit", Description = "Optional. The maximum number of records to return", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
|
||||||
public int? Limit { get; set; }
|
|
||||||
|
|
||||||
[ApiMember(Name = "MinDate", Description = "Optional. The minimum date. Format = ISO", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
|
||||||
public string MinDate { get; set; }
|
|
||||||
|
|
||||||
public bool? HasUserId { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[Authenticated(Roles = "Admin")]
|
|
||||||
public class ActivityLogService : BaseApiService
|
|
||||||
{
|
|
||||||
private readonly IActivityManager _activityManager;
|
|
||||||
|
|
||||||
public ActivityLogService(
|
|
||||||
ILogger<ActivityLogService> logger,
|
|
||||||
IServerConfigurationManager serverConfigurationManager,
|
|
||||||
IHttpResultFactory httpResultFactory,
|
|
||||||
IActivityManager activityManager)
|
|
||||||
: base(logger, serverConfigurationManager, httpResultFactory)
|
|
||||||
{
|
|
||||||
_activityManager = activityManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public object Get(GetActivityLogs request)
|
|
||||||
{
|
|
||||||
DateTime? minDate = string.IsNullOrWhiteSpace(request.MinDate) ?
|
|
||||||
(DateTime?)null :
|
|
||||||
DateTime.Parse(request.MinDate, null, DateTimeStyles.RoundtripKind).ToUniversalTime();
|
|
||||||
|
|
||||||
var filterFunc = new Func<IQueryable<ActivityLog>, IQueryable<ActivityLog>>(
|
|
||||||
entries => entries.Where(entry => entry.DateCreated >= minDate));
|
|
||||||
|
|
||||||
var result = _activityManager.GetPagedResult(filterFunc, request.StartIndex, request.Limit);
|
|
||||||
|
|
||||||
return ToOptimizedResult(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -25,7 +25,7 @@ namespace MediaBrowser.Common.Json.Converters
|
|||||||
/// <param name="typeToConvert">The type to convert.</param>
|
/// <param name="typeToConvert">The type to convert.</param>
|
||||||
/// <param name="options">The json serializer options.</param>
|
/// <param name="options">The json serializer options.</param>
|
||||||
/// <returns>Typed dictionary.</returns>
|
/// <returns>Typed dictionary.</returns>
|
||||||
/// <exception cref="NotSupportedException"></exception>
|
/// <exception cref="NotSupportedException">Dictionary key type not supported.</exception>
|
||||||
public override IDictionary<TKey, TValue> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
public override IDictionary<TKey, TValue> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||||
{
|
{
|
||||||
var convertedType = typeof(Dictionary<,>).MakeGenericType(typeof(string), typeToConvert.GenericTypeArguments[1]);
|
var convertedType = typeof(Dictionary<,>).MakeGenericType(typeof(string), typeToConvert.GenericTypeArguments[1]);
|
||||||
@ -70,8 +70,12 @@ namespace MediaBrowser.Common.Json.Converters
|
|||||||
var convertedDictionary = new Dictionary<string?, TValue>(value.Count);
|
var convertedDictionary = new Dictionary<string?, TValue>(value.Count);
|
||||||
foreach (var (k, v) in value)
|
foreach (var (k, v) in value)
|
||||||
{
|
{
|
||||||
convertedDictionary[k?.ToString()] = v;
|
if (k != null)
|
||||||
|
{
|
||||||
|
convertedDictionary[k.ToString()] = v;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JsonSerializer.Serialize(writer, convertedDictionary, options);
|
JsonSerializer.Serialize(writer, convertedDictionary, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ namespace MediaBrowser.Common.Json.Converters
|
|||||||
/// <returns>Conversion ability.</returns>
|
/// <returns>Conversion ability.</returns>
|
||||||
public override bool CanConvert(Type typeToConvert)
|
public override bool CanConvert(Type typeToConvert)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!typeToConvert.IsGenericType)
|
if (!typeToConvert.IsGenericType)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -16,7 +16,7 @@ namespace MediaBrowser.Common.Json
|
|||||||
/// When changing these options, update
|
/// When changing these options, update
|
||||||
/// Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
|
/// Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
|
||||||
/// -> AddJellyfinApi
|
/// -> AddJellyfinApi
|
||||||
/// -> AddJsonOptions
|
/// -> AddJsonOptions.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <returns>The default <see cref="JsonSerializerOptions" /> options.</returns>
|
/// <returns>The default <see cref="JsonSerializerOptions" /> options.</returns>
|
||||||
public static JsonSerializerOptions GetOptions()
|
public static JsonSerializerOptions GetOptions()
|
||||||
@ -35,24 +35,21 @@ namespace MediaBrowser.Common.Json
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets CamelCase json options.
|
/// Gets camelCase json options.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static JsonSerializerOptions CamelCase
|
/// <returns>The camelCase <see cref="JsonSerializerOptions" /> options.</returns>
|
||||||
{
|
public static JsonSerializerOptions GetCamelCaseOptions()
|
||||||
get
|
|
||||||
{
|
{
|
||||||
var options = GetOptions();
|
var options = GetOptions();
|
||||||
options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
|
options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets PascalCase json options.
|
/// Gets PascalCase json options.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static JsonSerializerOptions PascalCase
|
/// <returns>The PascalCase <see cref="JsonSerializerOptions" /> options.</returns>
|
||||||
{
|
public static JsonSerializerOptions GetPascalCaseOptions()
|
||||||
get
|
|
||||||
{
|
{
|
||||||
var options = GetOptions();
|
var options = GetOptions();
|
||||||
options.PropertyNamingPolicy = null;
|
options.PropertyNamingPolicy = null;
|
||||||
@ -60,4 +57,3 @@ namespace MediaBrowser.Common.Json
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user