2019-07-17 13:45:36 +02:00
|
|
|
using System.Threading.Tasks;
|
2020-02-12 15:16:19 +01:00
|
|
|
|
2019-07-17 13:45:36 +02:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
2019-12-28 15:52:59 +01:00
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
2020-02-12 15:16:19 +01:00
|
|
|
using PluralKit.Core;
|
|
|
|
|
|
|
|
namespace PluralKit.API
|
2019-07-17 13:45:36 +02:00
|
|
|
{
|
|
|
|
[ApiController]
|
2020-05-07 04:39:49 +02:00
|
|
|
[ApiVersion("1.0")]
|
2021-08-27 11:03:47 -04:00
|
|
|
[Route("v{version:apiVersion}/a")]
|
2019-07-17 13:45:36 +02:00
|
|
|
public class AccountController: ControllerBase
|
|
|
|
{
|
2020-08-29 13:46:27 +02:00
|
|
|
private readonly IDatabase _db;
|
|
|
|
private readonly ModelRepository _repo;
|
|
|
|
public AccountController(IDatabase db, ModelRepository repo)
|
2019-07-17 13:45:36 +02:00
|
|
|
{
|
2020-08-29 13:46:27 +02:00
|
|
|
_db = db;
|
|
|
|
_repo = repo;
|
2019-07-17 13:45:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[HttpGet("{aid}")]
|
2019-12-28 15:52:59 +01:00
|
|
|
public async Task<ActionResult<JObject>> GetSystemByAccount(ulong aid)
|
2019-07-17 13:45:36 +02:00
|
|
|
{
|
2021-09-29 21:51:38 -04:00
|
|
|
var system = await _repo.GetSystemByAccount(aid);
|
2020-08-29 13:46:27 +02:00
|
|
|
if (system == null)
|
|
|
|
return NotFound("Account not found.");
|
2021-08-27 11:03:47 -04:00
|
|
|
|
2020-06-16 01:15:59 +02:00
|
|
|
return Ok(system.ToJson(User.ContextFor(system)));
|
2019-07-17 13:45:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|