Files
AnilistSync/Jellyfin.Plugin.AnilistSync/API/Endpoints.cs
T
YannikMG c17d62fc62 Port to Jellyfin 10.11 (net9.0, IHostedService)
IServerEntryPoint was removed in favor of IHostedService; migrated
PlaybackScrobbler and updated PluginServiceRegistrator accordingly
(RegisterServices now takes IServerApplicationHost, AnilistApi moved
to a singleton so the hosted service can depend on it). Bumped
TargetFramework to net9.0 and targetAbi to 10.11.0.0.

Also fixed Endpoints.cs, which referenced an "DefaultAuthorization"
authorization policy that no longer resolves for plugin controllers
on 10.11, causing every API call to 500 instead of 401'ing when
unauthenticated. Verified end-to-end against a live 10.11.11 server:
plugin loads, OAuth re-auth works, and a real scrobble to Anilist
succeeded.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-31 23:10:40 +02:00

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]
[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);
}
}
}