Support Jellyfin 10.7

This commit is contained in:
crobibero
2021-02-24 10:29:09 -07:00
parent 1458fd7534
commit 84a1d0934e
35 changed files with 699 additions and 751 deletions
+67
View File
@@ -0,0 +1,67 @@
using System;
using System.Threading.Tasks;
using Jellyfin.Plugin.Simkl.API.Objects;
using Jellyfin.Plugin.Simkl.API.Responses;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Jellyfin.Plugin.Simkl.API
{
/// <summary>
/// The simkl endpoints.
/// </summary>
[ApiController]
[Authorize(Policy = "DefaultAuthorization")]
[Route("Simkl")]
public class Endpoints : ControllerBase
{
private readonly SimklApi _simklApi;
/// <summary>
/// Initializes a new instance of the <see cref="Endpoints"/> class.
/// </summary>
/// <param name="simklApi">Instance of the <see cref="SimklApi"/>.</param>
public Endpoints(SimklApi simklApi)
{
_simklApi = simklApi;
}
/// <summary>
/// Gets the oauth pin.
/// </summary>
/// <returns>The oauth pin.</returns>
[HttpGet("oauth/pin")]
public async Task<ActionResult<CodeResponse?>> GetPin()
{
return await _simklApi.GetCode();
}
/// <summary>
/// Gets the status for the code.
/// </summary>
/// <param name="userCode">The user auth code.</param>
/// <returns>The code status response.</returns>
[HttpGet("oauth/pin/{userCode}")]
public async Task<ActionResult<CodeStatusResponse?>> GetPinStatus([FromRoute] string userCode)
{
return await _simklApi.GetCodeStatus(userCode);
}
/// <summary>
/// Gets the settings for the user.
/// </summary>
/// <param name="userId">The user id.</param>
/// <returns>The user settings.</returns>
[HttpGet("users/settings/{userId}")]
public async Task<ActionResult<UserSettings?>> GetUserSettings([FromRoute] Guid userId)
{
var userConfiguration = SimklPlugin.Instance?.Configuration.GetByGuid(userId);
if (userConfiguration == null)
{
return NotFound();
}
return await _simklApi.GetUserSettings(userConfiguration.UserToken);
}
}
}