2019-07-17 11:45:36 +00:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
2019-12-28 14:52:59 +00:00
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
2020-02-12 14:16:19 +00:00
|
|
|
using PluralKit.Core;
|
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
namespace PluralKit.API;
|
|
|
|
|
|
|
|
[ApiController]
|
|
|
|
[ApiVersion("1.0")]
|
|
|
|
[Route("v{version:apiVersion}/a")]
|
|
|
|
public class AccountController: ControllerBase
|
2019-07-17 11:45:36 +00:00
|
|
|
{
|
2021-11-27 02:10:56 +00:00
|
|
|
private readonly IDatabase _db;
|
|
|
|
private readonly ModelRepository _repo;
|
|
|
|
|
|
|
|
public AccountController(IDatabase db, ModelRepository repo)
|
2019-07-17 11:45:36 +00:00
|
|
|
{
|
2021-11-27 02:10:56 +00:00
|
|
|
_db = db;
|
|
|
|
_repo = repo;
|
|
|
|
}
|
2019-07-17 11:45:36 +00:00
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
[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
|
|
|
|
2021-11-27 02:10:56 +00:00
|
|
|
return Ok(system.ToJson(User.ContextFor(system)));
|
2019-07-17 11:45:36 +00:00
|
|
|
}
|
|
|
|
}
|