PluralKit/PluralKit.API/Controllers/v1/AccountController.cs

32 lines
738 B
C#
Raw Normal View History

using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using PluralKit.Core;
namespace PluralKit.API;
[ApiController]
[ApiVersion("1.0")]
[Route("v{version:apiVersion}/a")]
public class AccountController: ControllerBase
{
private readonly IDatabase _db;
private readonly ModelRepository _repo;
public AccountController(IDatabase db, ModelRepository repo)
{
_db = db;
_repo = repo;
}
[HttpGet("{aid}")]
public async Task<ActionResult<JObject>> GetSystemByAccount(ulong aid)
{
var system = await _repo.GetSystemByAccount(aid);
if (system == null)
return NotFound("Account not found.");
2021-08-27 15:03:47 +00:00
return Ok(system.ToJson(User.ContextFor(system)));
}
}