- csproj: net9.0 -> net10.0, version 2.1.0.0 -> 3.0.0.0 - Jellyfin.Controller 10.*-* -> 12.*-* with ExcludeAssets="runtime" - drop redundant Microsoft.Extensions.Http ref (NU1510 under the .NET 10 SDK; IHttpClientFactory comes from the Microsoft.AspNetCore.App framework ref) - NetAnalyzers 9.0.0 -> 10.0.100 - Endpoints: bare [Authorize] -> [Authorize(Policy = "DefaultAuthorization")] now that legacy authorization is disabled by default - drop unused using in AnilistApi.cs - build.yaml + manifest.json: 3.0.0.0 / abi 12.0.0.0 entry - gitignore local dist/ release-artifact dir Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Jellyfin.Plugin.AnilistSync.API
|
|
{
|
|
/// <summary>
|
|
/// Anilist endpoints.
|
|
/// </summary>
|
|
[ApiController]
|
|
[Authorize(Policy = "DefaultAuthorization")]
|
|
[Route("AnilistSync")]
|
|
public class Endpoints : ControllerBase
|
|
{
|
|
private readonly AnilistApi _anilistApi;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instacne fo the <see cref="Endpoints"/> class.
|
|
/// </summary>
|
|
/// <param name="anilistApi"></param>
|
|
public Endpoints(AnilistApi anilistApi)
|
|
{
|
|
_anilistApi = anilistApi;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the OAuth token.
|
|
/// </summary>
|
|
/// <param name="userCode">User code.</param>
|
|
/// <returns>Code response containing token.</returns>
|
|
[HttpGet("oauth/token/{userCode}")]
|
|
public async Task<ActionResult<CodeResponse?>> GetToken([FromRoute] string userCode)
|
|
{
|
|
return await _anilistApi.GetToken(userCode);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the currently authenticated user
|
|
/// </summary>
|
|
/// <param name="userId">The user ID.</param>
|
|
/// <returns>Root object containing User object</returns>
|
|
[HttpGet("users/settings/{userId}")]
|
|
public async Task<ActionResult<RootObject?>> GetUser([FromRoute] Guid userId)
|
|
{
|
|
var userConfiguration = Plugin.Instance?.Configuration.GetByGuid(userId);
|
|
if (userConfiguration == null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
return await _anilistApi.GetUser(userConfiguration.UserToken);
|
|
}
|
|
|
|
}
|
|
} |